1 package org.onap.pnfsimulator.simulator.client;
3 import static org.mockito.ArgumentMatchers.any;
4 import static org.mockito.Mockito.doReturn;
5 import static org.mockito.Mockito.doThrow;
6 import static org.mockito.Mockito.never;
7 import static org.mockito.Mockito.verify;
8 import static org.mockito.MockitoAnnotations.initMocks;
10 import java.io.IOException;
11 import org.apache.http.HttpResponse;
12 import org.apache.http.client.HttpClient;
13 import org.junit.jupiter.api.BeforeEach;
14 import org.junit.jupiter.api.Test;
15 import org.mockito.Mock;
17 class HttpClientAdapterImplTest {
19 private HttpClientAdapter adapter;
22 private HttpClient httpClient;
24 private HttpResponse httpResponse;
29 adapter = new HttpClientAdapterImpl(httpClient);
33 void send_should_successfully_send_request_given_valid_url() throws IOException {
34 doReturn(httpResponse).when(httpClient).execute(any());
36 adapter.send("test-msg", "http://valid-url");
38 verify(httpClient).execute(any());
39 verify(httpResponse).getStatusLine();
43 void send_should_not_send_request_given_invalid_url() throws IOException {
44 doThrow(new IOException("test")).when(httpClient).execute(any());
46 adapter.send("test-msg", "http://invalid-url");
48 verify(httpClient).execute(any());
49 verify(httpResponse, never()).getStatusLine();