summaryrefslogtreecommitdiffstats
path: root/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-05-23 15:31:11 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-05-24 11:50:34 +0200
commit7ddaf390698fe5ae9143d91e7011059b3973f8ce (patch)
tree4d483f24c6b73ce2e0d0a8237410856f8e01edb6 /prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java
parentb6bc8925a354825545b8527879e0f687b0dbab3a (diff)
Refactor of prh-aai-client
Change-Id: Idbca6fe4c050c789f4479164846437039d3b549d Issue-ID: DCAEGEN2-451 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java')
-rw-r--r--prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java31
1 files changed, 11 insertions, 20 deletions
diff --git a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java
index 3cb84206..aa6810e3 100644
--- a/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java
+++ b/prh-dmaap-client/src/test/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImplTest.java
@@ -42,18 +42,15 @@ import static org.mockito.Mockito.when;
public class ExtendedDmaapProducerHttpClientImplTest {
private static ExtendedDmaapProducerHttpClientImpl objectUnderTest;
-
private static DmaapPublisherConfiguration configurationMock = mock(DmaapPublisherConfiguration.class);
private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class);
private static ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
-
- private static Optional<String> expectedResult = Optional.empty();
- private static final String RESPONSE_SUCCESS = "200";
- private static final String RESPONSE_FAILURE = "404";
+ private static Integer expectedResult;
+ private static final Integer RESPONSE_SUCCESS = 200;
+ private static final Integer RESPONSE_FAILURE = 404;
@BeforeAll
public static void init() throws NoSuchFieldException, IllegalAccessException {
-
when(configurationMock.dmaapHostName()).thenReturn("54.45.33.2");
when(configurationMock.dmaapProtocol()).thenReturn("https");
when(configurationMock.dmaapPortNumber()).thenReturn(1234);
@@ -61,35 +58,29 @@ public class ExtendedDmaapProducerHttpClientImplTest {
when(configurationMock.dmaapUserPassword()).thenReturn("PRH");
when(configurationMock.dmaapContentType()).thenReturn("application/json");
when(configurationMock.dmaapTopicName()).thenReturn("pnfReady");
-
objectUnderTest = new ExtendedDmaapProducerHttpClientImpl(configurationMock);
-
setField();
}
@Test
public void getHttpResponsePost_success() throws IOException {
- expectedResult = Optional.of(RESPONSE_SUCCESS);
-
+ expectedResult = RESPONSE_SUCCESS;
when(closeableHttpClientMock.execute(any(HttpPost.class), any(ResponseHandler.class)))
- .thenReturn(expectedResult);
-
- Optional<String> actualResult = objectUnderTest.getHttpProducerResponse(consumerDmaapModel);
-
- Assertions.assertEquals(expectedResult.get(), actualResult.get());
+ .thenReturn(Optional.of(expectedResult));
+ Optional<Integer> actualResult = objectUnderTest.getHttpProducerResponse(consumerDmaapModel);
+ Assertions.assertEquals(expectedResult, actualResult.get());
}
@Test
public void getExtendedDetails_returnsFailure() throws IOException {
- expectedResult = Optional.of(RESPONSE_FAILURE);
+ expectedResult = RESPONSE_FAILURE;
when(closeableHttpClientMock.execute(any(HttpPost.class), any(ResponseHandler.class)))
- .thenReturn(Optional.empty());
- Optional<String> actualResult = objectUnderTest.getHttpProducerResponse(consumerDmaapModel);
- Assertions.assertEquals(Optional.empty(), actualResult);
+ .thenReturn(Optional.of(expectedResult));
+ Optional<Integer> actualResult = objectUnderTest.getHttpProducerResponse(consumerDmaapModel);
+ Assertions.assertEquals(expectedResult, actualResult.get());
}
-
private static void setField() throws NoSuchFieldException, IllegalAccessException {
Field field = objectUnderTest.getClass().getDeclaredField("closeableHttpClient");
field.setAccessible(true);