summaryrefslogtreecommitdiffstats
path: root/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java')
-rw-r--r--prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java
index 7f3978bd..59c90dc8 100644
--- a/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java
+++ b/prh-aai-client/src/test/java/org/onap/dcaegen2/services/service/AAIProducerClientTest.java
@@ -27,7 +27,9 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.services.config.AAIClientConfiguration;
-import org.onap.dcaegen2.services.utils.HttpRequestDetails;
+import org.onap.dcaegen2.services.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.services.model.ConsumerDmaapModelForUnitTest;
+
import java.io.IOException;
import java.lang.reflect.Field;
@@ -41,17 +43,17 @@ import static org.mockito.Mockito.when;
public class AAIProducerClientTest {
+ private static final Integer SUCCESS = 200;
private static AAIProducerClient testedObject;
private static AAIClientConfiguration aaiHttpClientConfigurationMock = mock(AAIClientConfiguration.class);
private static CloseableHttpClient closeableHttpClientMock = mock(CloseableHttpClient.class);
- private static HttpRequestDetails httpRequestDetailsMock = mock(HttpRequestDetails.class);
- private static final String JsonBody = "{\"ipaddress-v4-oam\":\"11.22.33.155\"}";
- private static final String SUCCESS = "200";
- private static final String PNF_NAME = "nokia-pnf-nhfsadhff";
+ private static ConsumerDmaapModel consumerDmaapModel = new ConsumerDmaapModelForUnitTest();
+
@BeforeAll
public static void init() throws NoSuchFieldException, IllegalAccessException {
+ //given
Map<String, String> aaiHeaders = new HashMap<>();
aaiHeaders.put("X-FromAppId", "prh");
aaiHeaders.put("X-TransactionId", "vv-temp");
@@ -59,29 +61,28 @@ public class AAIProducerClientTest {
aaiHeaders.put("Real-Time", "true");
aaiHeaders.put("Content-Type", "application/merge-patch+json");
+ //when
when(aaiHttpClientConfigurationMock.aaiHost()).thenReturn("eucalyptus.es-si-eu-dhn-20.eecloud.nsn-net.net");
when(aaiHttpClientConfigurationMock.aaiProtocol()).thenReturn("https");
when(aaiHttpClientConfigurationMock.aaiHostPortNumber()).thenReturn(1234);
when(aaiHttpClientConfigurationMock.aaiUserName()).thenReturn("PRH");
when(aaiHttpClientConfigurationMock.aaiUserPassword()).thenReturn("PRH");
-
- when(httpRequestDetailsMock.aaiAPIPath()).thenReturn("/aai/v11/network/pnfs/pnf");
-
- when(httpRequestDetailsMock.headers()).thenReturn(aaiHeaders);
- when(httpRequestDetailsMock.pnfName()).thenReturn(PNF_NAME);
- when(httpRequestDetailsMock.jsonBody()).thenReturn(Optional.of(JsonBody));
+ when(aaiHttpClientConfigurationMock.aaiBasePath()).thenReturn("/aai/v11");
+ when(aaiHttpClientConfigurationMock.aaiPnfPath()).thenReturn("/network/pnfs/pnf");
+ when(aaiHttpClientConfigurationMock.aaiHeaders()).thenReturn(aaiHeaders);
testedObject = new AAIProducerClient(aaiHttpClientConfigurationMock);
setField();
}
@Test
- public void getHttpResponsePatch_success() throws IOException {
-
+ public void getHttpResponsePatch_shouldReturnSuccessStatusCode() throws IOException {
+ //when
when(closeableHttpClientMock.execute(any(HttpPatch.class), any(ResponseHandler.class)))
.thenReturn(Optional.of(SUCCESS));
- Optional<String> actualResult = testedObject.getHttpResponse(httpRequestDetailsMock);
+ Optional<Integer> actualResult = testedObject.getHttpResponse(consumerDmaapModel);
+ //then
Assertions.assertEquals(SUCCESS, actualResult.get());
}