aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-03-28 17:12:51 +0200
committerMatthieuGeerebaert <matthieu.geerebaert@orange.com>2018-04-03 23:36:25 +0200
commit9ac6c3cc7e3f4aec9ba69e7a5bb0800471c4e8dc (patch)
tree55122c3e6f668250d19d917e668066cf8647f125 /src/test/java
parent99bf586a6eb9799c4f33e43976d741f2807ea287 (diff)
Add service inventory
- Add service inventory operations get and find - Consumes AAI - Add tests Change-Id: If04ada259b7a172c1dbaac3649047cdb2d9dd5bc Issue-ID: EXTAPI-39 Signed-off-by: MatthieuGeerebaert <matthieu.geerebaert@orange.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/nbi/apis/resources/ApiTest.java74
-rw-r--r--src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java88
2 files changed, 161 insertions, 1 deletions
diff --git a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java b/src/test/java/org/onap/nbi/apis/resources/ApiTest.java
index 05d332c..df2fb24 100644
--- a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java
+++ b/src/test/java/org/onap/nbi/apis/resources/ApiTest.java
@@ -8,6 +8,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.nbi.apis.servicecatalog.ServiceSpecificationResource;
+import org.onap.nbi.apis.serviceinventory.ServiceInventoryResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
@@ -26,12 +27,14 @@ public class ApiTest {
String realServerPort;
-
static public WireMockServer wireMockServer = new WireMockServer(8091);
@Autowired
ServiceSpecificationResource serviceSpecificationResource;
+ @Autowired
+ ServiceInventoryResource serviceInventoryResource;
+
@BeforeClass
public static void setUp() throws Exception {
wireMockServer.start();
@@ -48,6 +51,8 @@ public class ApiTest {
wireMockServer.resetToDefaultMappings();
}
+ // serviceCatalog
+
@Test
@Ignore
public void testServiceResourceGetCatalog() throws Exception {
@@ -86,4 +91,71 @@ public class ApiTest {
}
+ // serviceInventory
+
+ @Test
+ public void testServiceResourceGetInventory() throws Exception {
+
+ String serviceName = "vFW";
+ String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb";
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.name", serviceName);
+ params.add("relatedParty.id", "6490");
+ ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+ ServiceInventoryAssertions.assertServiceInventoryGet(resource);
+
+ }
+
+
+ @Test
+ public void testServiceResourceGetInventoryWithServiceSpecId() throws Exception {
+
+ String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb";
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.id", "1e3feeb0-8e36-46c6-862c-236d9c626439");
+ params.add("relatedParty.id", "6490");
+ ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+ ServiceInventoryAssertions.assertServiceInventoryGet(resource);
+
+ }
+
+
+ @Test
+ public void testServiceInventoryFind() throws Exception {
+
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ String serviceName = "vFW";
+ params.add("serviceSpecification.name", serviceName);
+ params.add("relatedParty.id", "6490");
+
+ ResponseEntity<Object> resource = serviceInventoryResource.findServiceInventory(params);
+ ServiceInventoryAssertions.assertServiceInventoryFind(resource);
+
+ }
+
+
+ @Test
+ public void testServiceInventoryFindWithServiceSpecId() throws Exception {
+
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.id", "1e3feeb0-8e36-46c6-862c-236d9c626439");
+ params.add("relatedParty.id", "6490");
+
+ ResponseEntity<Object> resource = serviceInventoryResource.findServiceInventory(params);
+ ServiceInventoryAssertions.assertServiceInventoryFind(resource);
+
+ }
+
+
+ @Test
+ public void testServiceInventoryFindWithoutParameter() throws Exception {
+
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("relatedParty.id", "6490");
+
+ ResponseEntity<Object> resource = serviceInventoryResource.findServiceInventory(params);
+ ServiceInventoryAssertions.assertServiceInventoryFindWithoutParameter(resource);
+
+ }
+
}
diff --git a/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java b/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java
new file mode 100644
index 0000000..e8afc9c
--- /dev/null
+++ b/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java
@@ -0,0 +1,88 @@
+package org.onap.nbi.apis.resources;
+
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ServiceInventoryAssertions {
+
+
+
+
+ public static void assertServiceInventoryGet(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(2);
+ LinkedHashMap resource1 = (LinkedHashMap) ((ArrayList) service.get("supportingResource")).get(0);
+ assertThat(resource1.get("id")).isEqualTo("cb80fbb6-9aa7-4ac5-9541-e14f45de533e");
+ assertThat(resource1.get("name")).isEqualTo("NewFreeRadius-VNF-instance-01");
+ assertThat(resource1.get("status")).isEqualTo("PREPROV");
+ assertThat(resource1.get("modelInvariantId")).isEqualTo("f5993703-977f-4346-a1c9-c1884f8cfd8d");
+ assertThat(resource1.get("modelVersionId")).isEqualTo("902438f7-1e4c-492d-b7cc-8650e13b8aeb");
+ assertThat(resource1.get("@referredType")).isEqualTo("ONAP resource");
+ }
+
+
+ public static void assertServiceInventoryFind(ResponseEntity<Object> resource) {
+ assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
+ ArrayList body = (ArrayList)resource.getBody();
+ assertThat(body.size()).isEqualTo(1);
+ LinkedHashMap service1 = (LinkedHashMap)body.get(0);
+ assertThat(service1.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb");
+ assertThat(service1.get("name")).isEqualTo("NewFreeRadius-service-instance-01");
+ LinkedHashMap relatedParty = (LinkedHashMap) service1.get("relatedParty");
+ assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer");
+ assertThat(relatedParty.get("id")).isEqualTo("6490");
+ LinkedHashMap serviceSpecification = (LinkedHashMap) service1.get("serviceSpecification");
+ assertThat(serviceSpecification.get("name")).isEqualTo("vFW");
+ assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5");
+ }
+
+
+ public static void assertServiceInventoryFindWithoutParameter(ResponseEntity<Object> resource) {
+ assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
+ ArrayList body = (ArrayList)resource.getBody();
+ assertThat(body.size()).isEqualTo(2);
+ LinkedHashMap service1 = (LinkedHashMap)body.get(0);
+ assertThat(service1.get("id")).isEqualTo("vfw-service-id");
+ assertThat(service1.get("name")).isEqualTo("vfw-service-name");
+ LinkedHashMap relatedParty = (LinkedHashMap) service1.get("relatedParty");
+ assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer");
+ assertThat(relatedParty.get("id")).isEqualTo("6490");
+ LinkedHashMap serviceSpecification = (LinkedHashMap) service1.get("serviceSpecification");
+ assertThat(serviceSpecification.get("name")).isEqualTo("vFW-service-2VF-based");
+ assertThat(serviceSpecification.get("id")).isEqualTo("9vfw-service-modek-version-id");
+
+
+ LinkedHashMap service2 = (LinkedHashMap)body.get(1);
+ assertThat(service2.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb");
+ assertThat(service2.get("name")).isEqualTo("NewFreeRadius-service-instance-01");
+ relatedParty = (LinkedHashMap) service1.get("relatedParty");
+ assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer");
+ assertThat(relatedParty.get("id")).isEqualTo("6490");
+ serviceSpecification = (LinkedHashMap) service2.get("serviceSpecification");
+ assertThat(serviceSpecification.get("name")).isEqualTo("vFW");
+ assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5");
+
+ }
+
+}