fix NPE on NBI serviceInventory 63/44163/1
authorromaingimbert <romain.gimbert@orange.com>
Mon, 23 Apr 2018 13:44:32 +0000 (15:44 +0200)
committerromaingimbert <romain.gimbert@orange.com>
Mon, 23 Apr 2018 13:46:03 +0000 (15:46 +0200)
- test with service without vnf

Change-Id: If92057a04e2d3263876d87a54588b4b8ca53a8d0
Issue-ID: EXTAPI-69
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
src/test/java/org/onap/nbi/apis/ApiTest.java
src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java
src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json [new file with mode: 0644]

index c65f60b..563760e 100644 (file)
@@ -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 {
index 56a6180..f68b82f 100644 (file)
@@ -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 (file)
index 0000000..2765c77
--- /dev/null
@@ -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