From f0c44b14013d7418c19ba4cd7f9a5a3043648d5c Mon Sep 17 00:00:00 2001 From: "Leigh, Phillip (pl876u)" Date: Thu, 28 Feb 2019 18:14:33 -0500 Subject: AaiCtxBuldr:Set MaxInstanceMap to 0 & fix macAddr This fix also address the resourceLink issue. Issue-ID: LOG-998 Issue-ID: LOG-766 Change-Id: I8b3eef61cebf93690aaa0291f201902281817020 Signed-off-by: Leigh, Phillip (pl876u) --- .../pomba_aai_context_builder/RestUtilTest.java | 82 ++++++---------------- .../test/RestServiceTest.java | 52 +++++--------- src/test/resources/junit/queryNodeData-1.json | 8 --- .../junit/queryNodeData-nullResourceLink.json | 8 --- 4 files changed, 41 insertions(+), 109 deletions(-) delete mode 100644 src/test/resources/junit/queryNodeData-1.json delete mode 100644 src/test/resources/junit/queryNodeData-nullResourceLink.json (limited to 'src/test') diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java index e184f4d..8c445c1 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.List; import java.util.UUID; import org.junit.Rule; @@ -92,33 +93,6 @@ public class RestUtilTest { assertTrue(!RestUtil.isEmptyJson("{Not Empty}")); } - @Test - public void testObtainResouceLinkBasedOnServiceInstanceFromAAI() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); - - String resourceLinkUlr = RestUtil.obtainResouceLinkBasedOnServiceInstanceFromAAI(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, serviceInstanceId, transactionId, aaiBasicAuthorization); - - String returnedInstanceId = resourceLinkUlr.substring(resourceLinkUlr.lastIndexOf("/")+1).trim(); - assertEquals(serviceInstanceId, returnedInstanceId); - } - - @Test - public void testObtainResouceLinkBasedOnServiceInstanceFromAAI_nullResourceLink() throws Exception { - String transactionId = UUID.randomUUID().toString(); - String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - addResponse(queryNodeUrl, "junit/queryNodeData-nullResourceLink.json", aaiEnricherRule); - - try { - RestUtil.obtainResouceLinkBasedOnServiceInstanceFromAAI(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, serviceInstanceId, transactionId, aaiBasicAuthorization); - } catch (AuditException e) { - assertTrue(e.getMessage().contains("JSONObject[\"resource-link\"] not found")); - } - } - private void addResponse(String path, String classpathResource, WireMockRule thisMock) throws IOException { String payload = readFully(ClassLoader.getSystemResourceAsStream(classpathResource)); thisMock.stubFor(get(path).willReturn(okJson(payload))); @@ -136,6 +110,9 @@ public class RestUtilTest { return content.toString(); } + private static String generateGetCustomerInfoUrl (String baseURL, String aaiPathToSearchNodeQuery,String serviceInstanceId) { + return baseURL + MessageFormat.format(aaiPathToSearchNodeQuery, serviceInstanceId); + } //// @Test @@ -143,11 +120,11 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); + // 2. simulate the response of AAI (1 vnf and 1 pnf) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance.json", aaiEnricherRule); // 3. simulate the rsp of VNF @@ -171,12 +148,11 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); + // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -216,11 +192,9 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf and 1 pnf) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance.json", aaiEnricherRule); // 3. simulate the rsp of VNF @@ -247,12 +221,9 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -295,12 +266,9 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set3.json", aaiEnricherRule); // 3. simulate the rsp of l3-network @@ -328,12 +296,9 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -369,12 +334,9 @@ public class RestUtilTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java index 8e50484..c97ea1a 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/test/RestServiceTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.Collections; import java.util.List; import java.util.UUID; @@ -111,23 +112,25 @@ public class RestServiceTest { return headers; } + private static String generateGetCustomerInfoUrl (String baseURL, String aaiPathToSearchNodeQuery,String serviceInstanceId) { + return baseURL + MessageFormat.format(aaiPathToSearchNodeQuery, serviceInstanceId); + } + ///Verify the relationship serviceInstanceId -> vnf -> vserver -> pserver @Test public void testGetContext_VSERVER_PSERVER() throws Exception { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -175,17 +178,14 @@ public class RestServiceTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -255,17 +255,14 @@ public class RestServiceTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -314,17 +311,14 @@ public class RestServiceTest { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) @@ -372,17 +366,14 @@ public class RestServiceTest { public void testGetContext_LogicalLink_in_service_level() throws Exception { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set4.json", aaiEnricherRule); // 3. simulate the rsp of logical-link @@ -411,16 +402,14 @@ public class RestServiceTest { public void testGetContext_LogicalLink_in_PInterface_level_with_PNF() throws Exception { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf and 1 pnf) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance.json", aaiEnricherRule); // 3. simulate the rsp of VNF @@ -464,17 +453,14 @@ public class RestServiceTest { public void testGetContext_LogicalLink_in_PInterface_level_with_PSERVER() throws Exception { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json - String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + String queryNodeUrl = generateGetCustomerInfoUrl("", aaiPathToSearchNodeQuery, serviceInstanceId); // Test with No Partner Name final MultivaluedMap multivaluedMapImpl = buildHeaders( transactionId, testRestHeaders, httpBasicAuthorization); - // 1. simulate the response to obtainResourceLink based on ServiceInstanceId - addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf) - // note: match serviceInstanceId in (1) - addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( queryNodeUrl, "junit/aai-service-instance_set2.json", aaiEnricherRule); // 3. simulate the rsp of VNF (with 1 vserver) diff --git a/src/test/resources/junit/queryNodeData-1.json b/src/test/resources/junit/queryNodeData-1.json deleted file mode 100644 index ea4bd89..0000000 --- a/src/test/resources/junit/queryNodeData-1.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "result-data": [ - { - "resource-type": "service-instance", - "resource-link": "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb" - } - ] -} diff --git a/src/test/resources/junit/queryNodeData-nullResourceLink.json b/src/test/resources/junit/queryNodeData-nullResourceLink.json deleted file mode 100644 index 5b7a272..0000000 --- a/src/test/resources/junit/queryNodeData-nullResourceLink.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "result-data": [ - { - "resource-type": "service-instance", - "related-link": "/aai/v13/network/vnfcs/vnfc/zrdm5aepdg01vmg003" - } - ] -} -- cgit 1.2.3-korg