diff options
author | romaingimbert <romain.gimbert@orange.com> | 2018-04-23 15:44:32 +0200 |
---|---|---|
committer | romaingimbert <romain.gimbert@orange.com> | 2018-04-23 15:46:03 +0200 |
commit | 3e79da4249c0c76ddf25af5c0447fa41f2eceeed (patch) | |
tree | 8d643b21c98ef14be670cf8a2690b2a9acb5d8f5 /src/test | |
parent | 8252e55861286bfea1aa910b6a543cdbdde15808 (diff) |
fix NPE on NBI serviceInventory
- test with service without vnf
Change-Id: If92057a04e2d3263876d87a54588b4b8ca53a8d0
Issue-ID: EXTAPI-69
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/test')
3 files changed, 54 insertions, 0 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java index c65f60b..563760e 100644 --- a/src/test/java/org/onap/nbi/apis/ApiTest.java +++ b/src/test/java/org/onap/nbi/apis/ApiTest.java @@ -180,6 +180,19 @@ public class ApiTest { } + @Test + public void testServiceResourceGetInventoryWithoutRelationShipList() throws Exception { + + String serviceName = "vFW"; + String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList"; + MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); + params.add("serviceSpecification.name", serviceName); + params.add("relatedParty.id", "6490"); + ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params); + ServiceInventoryAssertions.assertServiceInventoryGetWithoutList(resource); + + } + @Test public void testServiceResourceGetInventoryWithServiceSpecId() throws Exception { diff --git a/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java index 56a6180..f68b82f 100644 --- a/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java +++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java @@ -54,6 +54,28 @@ public class ServiceInventoryAssertions { } + public static void assertServiceInventoryGetWithoutList(ResponseEntity<Object> resource) { + assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); + LinkedHashMap service = (LinkedHashMap) resource.getBody(); + assertThat(service.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"); + assertThat(service.get("name")).isEqualTo("NewFreeRadius-service-instance-01"); + assertThat(service.get("hasStarted")).isEqualTo("yes"); + assertThat(service.get("type")).isEqualTo("service-instance"); + assertThat(service.get("@type")).isEqualTo("serviceONAP"); + LinkedHashMap relatedParty = (LinkedHashMap) service.get("relatedParty"); + assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer"); + assertThat(relatedParty.get("id")).isEqualTo("6490"); + LinkedHashMap serviceSpecification = (LinkedHashMap) service.get("serviceSpecification"); + assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5"); + assertThat(serviceSpecification.get("invariantUUID")).isEqualTo("709d157b-52fb-4250-976e-7133dff5c347"); + assertThat(serviceSpecification.get("@type")).isEqualTo("ONAPservice"); + + assertThat(((ArrayList) service.get("supportingResource")).size()).isEqualTo(0); + + } + + + public static void assertServiceInventoryFind(ResponseEntity<Object> resource) { assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); ArrayList body = (ArrayList) resource.getBody(); diff --git a/src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json b/src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json new file mode 100644 index 0000000..2765c77 --- /dev/null +++ b/src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json @@ -0,0 +1,19 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/vFW/service-instances/service-instance/e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList" + }, + "response": { + "status": 200, + "jsonBody": { + "service-instance-id": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb", + "service-instance-name": "NewFreeRadius-service-instance-01", + "model-invariant-id": "709d157b-52fb-4250-976e-7133dff5c347", + "model-version-id": "98d95267-5e0f-4531-abf8-f14b90031dc5", + "resource-version": "1518508381261" + }, + "headers": { + "Content-Type": "application/json" + } + } +}
\ No newline at end of file |