X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vid-app-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fvid%2Faai%2FAaiClientTest.java;fp=vid-app-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fvid%2Faai%2FAaiClientTest.java;h=ecfe5a00547531a420305dc9e28ba275e43b74ed;hb=f78df9f30d5b7bda1b291bff34dd85bdd9411c12;hp=1a75c555cea0f9845dd7909d2c3749cd2698be99;hpb=a1d209deac01bc0f8f7be96a585bdbef9cc0cdb9;p=vid.git diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java index 1a75c555c..ecfe5a005 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/AaiClientTest.java @@ -148,6 +148,9 @@ public class AaiClientTest { private static String responseJsonNfRole = "/payload_jsons/changeManagement/vnfs-fromServiceInstance-filterNfRole.json"; private static String responseJsonCloudRegion ="/payload_jsons/changeManagement/vnfs-fromServiceInstance-filterByCloudRegion.json"; + private static String responseJsonDSLServiceInstance ="/payload_jsons/service-instance-by-subscriberid.json"; + private static String dslQueryPayloadByServiceInstanceId = "{\"dsl\":\"customer*('global-customer-id','SOME_GLOBAL_CUST_ID')>service-subscription>service-instance*('service-instance-id','SOME_SERVICE_INSTANCE_ID')\"}"; + private static String dslQueryPayloadByServiceInstanceName = "{\"dsl\":\"customer*('global-customer-id','SOME_GLOBAL_CUST_ID')>service-subscription>service-instance*('service-instance-name','SOME_SERVICE_INSTANCE_NAME')\"}"; @DataProvider public static Object[][] aaiPutCustomQueryData() { @@ -952,6 +955,54 @@ public class AaiClientTest { Mockito.verify(aaiClientMock).doAaiGet(argThat(s -> s.contains("customer/" + subscriberId + "?") && s.contains("depth=" + depth)),any(Boolean.class)); } + + @DataProvider + public static Object[][] aaiDSLPutServiceInstanceQueryData() { + return new Object[][] { + {"SOME_GLOBAL_CUST_ID", "Service Instance Id", "SOME_SERVICE_INSTANCE_ID", + dslQueryPayloadByServiceInstanceId, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID", 200}, + {"SOME_GLOBAL_CUST_ID", "Service Instance Name", "SOME_SERVICE_INSTANCE_NAME", + dslQueryPayloadByServiceInstanceName, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID", 200}, + {"SOME_GLOBAL_CUST_ID", "Service Instance Name", "SOME_SERVICE_INSTANCE_NAME", + dslQueryPayloadByServiceInstanceName, responseJsonDSLServiceInstance, "SOME_SERVICE_INSTANCE_ID",200}, + + }; + } + + @Test(dataProvider = "aaiDSLPutServiceInstanceQueryData") + public void testAaiDSLPutServiceInstanceQueryByParams( String globalCustomerId, + String identifierType, + String identifier, + String expectedPayload, + String responseBody, + String expectedSiId, + int responseHttpCode) { + + String queryFormat = "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true"; + + final ResponseWithRequestInfo mockedResponseWithRequestInfo = mockedResponseWithRequestInfo(Response.Status.OK, + TestUtils.readFileAsString(responseBody), + "dsl?format=resource&nodesOnly=true&depth=0&as-tree=true&Mock=True", + HttpMethod.PUT); + + when(aaiClientMock.doAaiPut(eq(queryFormat), anyString(), anyBoolean(), anyBoolean())).thenReturn(mockedResponseWithRequestInfo); + when(aaiClientMock.getServiceInstanceBySubscriberIdAndInstanceIdentifier(anyString(), anyString(), anyString())).thenCallRealMethod(); + + AaiResponse response = aaiClientMock.getServiceInstanceBySubscriberIdAndInstanceIdentifier(globalCustomerId, identifierType, identifier); + + verify(aaiClientMock).doAaiPut(eq(queryFormat), eq(expectedPayload), eq(false), eq(false)); + + assertEquals(response.getHttpCode(), responseHttpCode); + assertEquals(response.getT().getResults().get(0).getCustomer().getCustomerRelatedNodes().get(0).getCustomerServiceSubscription(). + getServiceSubscriptionRelatedNodes().get(0).getServiceInstance().serviceInstanceId, expectedSiId); + + assertEquals(response.getT().getResults().get(0).getCustomer().getSubscriberName(), "Mobility"); + + assertEquals(response.getT().getResults().get(0).getCustomer().getCustomerRelatedNodes().get(0).getCustomerServiceSubscription(). + getServiceSubscriptionRelatedNodes().get(0).getServiceInstance().orchestrationStatus, "SOME_ORCH_STATUS"); + + } + @Test public void testToModelVerStream() throws IOException {