summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTest.java591
-rw-r--r--src/test/java/org/onap/nbi/apis/ServiceOrderRepositoryTest.java45
-rw-r--r--src/test/java/org/onap/nbi/apis/StatusResourceTest.java (renamed from src/test/java/org/onap/nbi/apis/resources/StatusResourceTest.java)2
-rw-r--r--src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java (renamed from src/test/java/org/onap/nbi/apis/resources/ServiceCatalogAssertions.java)14
-rw-r--r--src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java (renamed from src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java)21
-rw-r--r--src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java206
-rw-r--r--src/test/java/org/onap/nbi/apis/resources/ApiTest.java161
7 files changed, 859 insertions, 181 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java
new file mode 100644
index 0000000..cdd9f61
--- /dev/null
+++ b/src/test/java/org/onap/nbi/apis/ApiTest.java
@@ -0,0 +1,591 @@
+package org.onap.nbi.apis;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.nbi.apis.assertions.ServiceCatalogAssertions;
+import org.onap.nbi.apis.assertions.ServiceInventoryAssertions;
+import org.onap.nbi.apis.assertions.ServiceOrderAssertions;
+import org.onap.nbi.apis.servicecatalog.ServiceSpecificationResource;
+import org.onap.nbi.apis.serviceinventory.ServiceInventoryResource;
+import org.onap.nbi.apis.serviceorder.ServiceOrderResource;
+import org.onap.nbi.apis.serviceorder.model.ActionType;
+import org.onap.nbi.apis.serviceorder.model.RelatedParty;
+import org.onap.nbi.apis.serviceorder.model.Service;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
+import org.onap.nbi.apis.serviceorder.model.StateType;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
+import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderInfoRepository;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
+import org.onap.nbi.apis.serviceorder.workflow.SOTaskProcessor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.stubbing.ListStubMappingsResult;
+import com.github.tomakehurst.wiremock.stubbing.StubMapping;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+public class ApiTest {
+
+ @LocalServerPort
+ int randomServerPort;
+
+ String realServerPort;
+
+ static public WireMockServer wireMockServer = new WireMockServer(8091);
+
+ @Autowired
+ ServiceSpecificationResource serviceSpecificationResource;
+
+ @Autowired
+ ServiceInventoryResource serviceInventoryResource;
+
+ @Autowired
+ ServiceOrderResource serviceOrderResource;
+
+ @Autowired
+ ServiceOrderRepository serviceOrderRepository;
+
+ @Autowired
+ ServiceOrderInfoRepository serviceOrderInfoRepository;
+
+ @Autowired
+ ExecutionTaskRepository executionTaskRepository;
+
+ @Autowired
+ SOTaskProcessor SoTaskProcessor;
+
+ static Validator validator;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ wireMockServer.start();
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+ }
+
+ @AfterClass
+ public static void tearsDown() throws Exception {
+ wireMockServer.stop();
+
+ }
+
+ @After
+ public void tearsDownUpPort() throws Exception {
+ executionTaskRepository.deleteAll();
+ serviceOrderInfoRepository.deleteAll();
+ serviceOrderRepository.deleteAll();
+ wireMockServer.resetToDefaultMappings();
+
+ }
+
+
+ public ExecutionTask getExecutionTask(String orderItemId) {
+ for (ExecutionTask executionTask : executionTaskRepository.findAll()) {
+ if (executionTask.getOrderItemId().equalsIgnoreCase(orderItemId)) {
+ return executionTask;
+ }
+
+ }
+ return null;
+ }
+
+ // serviceCatalog
+
+ @Test
+ @Ignore
+ public void testServiceResourceGetCatalog() throws Exception {
+
+ ResponseEntity<Object> resource =
+ serviceSpecificationResource.getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439", null);
+ ServiceCatalogAssertions.assertGetServiceCatalog(resource);
+
+ }
+
+ @Test
+ public void testServiceCatalogGetResourceWithoutTosca() throws Exception {
+
+ ResponseEntity<Object> resource = serviceSpecificationResource
+ .getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439_withoutTosca", null);
+ ServiceCatalogAssertions.asserGetServiceCatalogWithoutTosca(resource);
+
+ }
+
+ @Test
+ public void testServiceCatalogFind() throws Exception {
+
+ ResponseEntity<Object> resource = serviceSpecificationResource.findServiceSpecification(null);
+ ServiceCatalogAssertions.assertFindServiceCatalog(resource);
+
+ }
+
+
+ @Test
+ public void testServiceCatalogFindWithFilter() throws Exception {
+
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("fields", "name");
+ ResponseEntity<Object> resource = serviceSpecificationResource.findServiceSpecification(params);
+ ServiceCatalogAssertions.assertFindServiceCatalogWIthFilter(resource);
+
+ }
+
+ // 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);
+
+ }
+
+ @Test
+ public void testCreateServiceOrderResource() throws Exception {
+
+ ResponseEntity<Object> serviceOrder = serviceOrderResource
+ .createServiceOrder(ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD), null, null);
+ assertThat(serviceOrder.getStatusCodeValue()).isEqualTo(201);
+ ServiceOrder body = (ServiceOrder) serviceOrder.getBody();
+ assertThat(body.getId()).isNotNull();
+ assertThat(body.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+
+ }
+
+ @Test
+ public void testCheckServiceOrder() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+ }
+
+ @Test
+ public void testCheckServiceOrderWithGenericCustomer() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ testServiceOrder.setRelatedParty(new ArrayList<>());
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+ }
+
+ @Test
+ public void testCheckServiceOrderWithUnKnonwCustomer() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ List<RelatedParty> customers = new ArrayList<>();
+ RelatedParty customer = new RelatedParty();
+ customer.setId("new");
+ customer.setRole("ONAPcustomer");
+ customer.setName("romain");
+ customers.add(customer);
+ testServiceOrder.setRelatedParty(customers);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+ }
+
+ @Test
+ public void testCheckServiceOrderDelete() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.setState(StateType.ACKNOWLEDGED);
+ }
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+ }
+
+ @Test
+ public void testCheckServiceOrderDeleteRejected() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.getService().setId("no_response");
+
+ }
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ }
+
+ @Test
+ public void testCheckServiceOrderNoChange() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.setAction(ActionType.NOCHANGE);
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+ }
+
+ }
+
+
+
+ @Test
+ public void testCheckServiceOrderNoChangeAndDelete() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ if (serviceOrderItem.getId().equals("A")) {
+ serviceOrderItem.setAction(ActionType.NOCHANGE);
+ }
+ serviceOrderItem.setState(StateType.ACKNOWLEDGED);
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ if (serviceOrderItem.getId().equals("A"))
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+ }
+ }
+
+
+
+ @Test
+ public void testCheckServiceOrderRejected() throws Exception {
+
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrderRejected();
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ serviceOrderResource.scheduleCheckServiceOrders();
+
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED);
+
+ }
+
+ @Test
+ public void validateServiceOrderBeanWithAnnotation() {
+ ServiceOrder serviceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ Set violations = validator.validate(serviceOrder);
+ assertThat(violations).isEmpty();
+
+ ServiceOrderItem item = new ServiceOrderItem();
+ item.setAction(ActionType.DELETE);
+ item.setService(new Service());
+ serviceOrder.addOrderItemItem(item);
+
+ violations = validator.validate(serviceOrder);
+ assertThat(violations).isNotEmpty();
+ }
+
+
+
+ @Test
+ public void testFindAndGetServiceOrder() throws Exception {
+
+ ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.setState(StateType.ACKNOWLEDGED);
+ }
+ testServiceOrder.setExternalId("extid1");
+ testServiceOrder.setOrderDate(new Date());
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setDescription("toto");
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+
+ ServiceOrder testServiceOrder2 = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+ testServiceOrder2.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder2.setDescription("toto");
+ testServiceOrder2.setId("test2");
+ testServiceOrder2.setExternalId("extid2");
+ testServiceOrder2.setOrderDate(new Date());
+
+ serviceOrderRepository.save(testServiceOrder2);
+
+
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("fields", "id");
+
+ ResponseEntity<Object> serviceOrdersResponse = serviceOrderResource.findServiceOrder(params);
+ ArrayList serviceOrders = (ArrayList) serviceOrdersResponse.getBody();
+ assertThat(serviceOrders.size()).isEqualTo(2);
+
+ params.add("externalId", "extid1");
+ params.add("state", "acknowledged");
+
+ serviceOrdersResponse = serviceOrderResource.findServiceOrder(params);
+ serviceOrders = (ArrayList) serviceOrdersResponse.getBody();
+ assertThat(serviceOrders.size()).isEqualTo(1);
+
+ MultiValueMap<String, String> paramsDate = new LinkedMultiValueMap<>();
+ paramsDate.add("orderDate.gt", "2017-01-01 00:00:00.000");
+ paramsDate.add("orderDate.lt", "2030-01-01 00:00:00.000");
+ paramsDate.add("offset", "0");
+ paramsDate.add("limit", "2");
+
+ serviceOrdersResponse = serviceOrderResource.findServiceOrder(paramsDate);
+ serviceOrders = (ArrayList) serviceOrdersResponse.getBody();
+ assertThat(serviceOrders.size()).isEqualTo(2);
+
+
+ ResponseEntity<Object> serviceOrderResponse =
+ serviceOrderResource.getServiceOrder("test2", new LinkedMultiValueMap<>());
+ ServiceOrder serviceOrder = (ServiceOrder) serviceOrderResponse.getBody();
+ assertThat(serviceOrder).isNotNull();
+ }
+
+
+
+ @Test
+ public void testExecutionTaskSuccess() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
+ serviceOrderInfoRepository, executionTaskRepository, ActionType.ADD);
+ ExecutionTask executionTaskB;
+
+
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ if (serviceOrderItem.getId().equals("A")) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+ } else {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+ }
+ }
+
+ executionTaskB = getExecutionTask("B");
+ assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty();
+ executionTaskA = getExecutionTask("A");
+ assertThat(executionTaskA).isNull();
+
+ SoTaskProcessor.processOrderItem(executionTaskB);
+ serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+
+ }
+
+ executionTaskB = getExecutionTask("B");
+ assertThat(executionTaskB).isNull();
+
+
+ }
+
+
+ @Test
+ public void testExecutionTaskDeleteSuccess() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
+ serviceOrderInfoRepository, executionTaskRepository, ActionType.DELETE);
+ ExecutionTask executionTaskB;
+
+
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ if (serviceOrderItem.getId().equals("A")) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+ } else {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+ }
+ }
+
+ executionTaskB = getExecutionTask("B");
+ assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty();
+ executionTaskA = getExecutionTask("A");
+ assertThat(executionTaskA).isNull();
+
+ SoTaskProcessor.processOrderItem(executionTaskB);
+ serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED);
+
+ }
+
+ executionTaskB = getExecutionTask("B");
+ assertThat(executionTaskB).isNull();
+
+
+ }
+
+
+ @Test
+ public void testExecutionTaskFailed() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
+ serviceOrderInfoRepository, executionTaskRepository, ActionType.ADD);
+
+ ListStubMappingsResult listStubMappingsResult = wireMockServer.listAllStubMappings();
+ StubMapping mappingToDelete = null;
+ List<StubMapping> mappings = listStubMappingsResult.getMappings();
+ for (StubMapping mapping : mappings) {
+ if (mapping.getRequest().getUrl().equals("/ecomp/mso/infra/orchestrationRequests/v4/requestId")) {
+ mappingToDelete = mapping;
+ }
+ }
+ wireMockServer.removeStubMapping(mappingToDelete);
+
+
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ if (serviceOrderItem.getId().equals("A")) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS);
+ } else {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+ }
+ }
+ executionTaskA = getExecutionTask("A");
+ assertThat(executionTaskA.getNbRetries()).isEqualTo(2);
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ executionTaskA = getExecutionTask("A");
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ executionTaskA = getExecutionTask("A");
+ SoTaskProcessor.processOrderItem(executionTaskA);
+
+ serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED);
+
+ }
+
+ ExecutionTask executionTaskB = executionTaskRepository.findOne(Long.parseLong("2"));
+ assertThat(executionTaskB).isNull();
+
+
+ }
+
+}
diff --git a/src/test/java/org/onap/nbi/apis/ServiceOrderRepositoryTest.java b/src/test/java/org/onap/nbi/apis/ServiceOrderRepositoryTest.java
new file mode 100644
index 0000000..93c9000
--- /dev/null
+++ b/src/test/java/org/onap/nbi/apis/ServiceOrderRepositoryTest.java
@@ -0,0 +1,45 @@
+package org.onap.nbi.apis;
+
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
+import org.onap.nbi.apis.serviceorder.model.StateType;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class ServiceOrderRepositoryTest {
+
+ @Autowired
+ ServiceOrderRepository serviceOrderRepository;
+
+
+ @Before
+ public void setUp() {
+ ServiceOrder serviceOrder = new ServiceOrder();
+ serviceOrder.setId("test");
+ serviceOrder.setState(StateType.INPROGRESS);
+ serviceOrderRepository.save(serviceOrder);
+ }
+
+ @Test
+ public void findById() {
+ ServiceOrder result = serviceOrderRepository.findOne("test");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void findByState() {
+ List<ServiceOrder> result = serviceOrderRepository.findByState(StateType.INPROGRESS);
+ assertFalse(result.isEmpty());
+ }
+
+}
diff --git a/src/test/java/org/onap/nbi/apis/resources/StatusResourceTest.java b/src/test/java/org/onap/nbi/apis/StatusResourceTest.java
index 40e11c2..f988996 100644
--- a/src/test/java/org/onap/nbi/apis/resources/StatusResourceTest.java
+++ b/src/test/java/org/onap/nbi/apis/StatusResourceTest.java
@@ -1,4 +1,4 @@
-package org.onap.nbi.apis.resources;
+package org.onap.nbi.apis;
import com.fasterxml.jackson.databind.node.ObjectNode;
diff --git a/src/test/java/org/onap/nbi/apis/resources/ServiceCatalogAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java
index 19e2a2a..3f44640 100644
--- a/src/test/java/org/onap/nbi/apis/resources/ServiceCatalogAssertions.java
+++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceCatalogAssertions.java
@@ -1,13 +1,11 @@
-package org.onap.nbi.apis.resources;
+package org.onap.nbi.apis.assertions;
import com.fasterxml.jackson.databind.node.ObjectNode;
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;
@@ -20,7 +18,8 @@ public class ServiceCatalogAssertions {
assertThat(service.get("id")).isEqualTo("1e3feeb0-8e36-46c6-862c-236d9c626439");
assertThat(service.get("name")).isEqualTo("vFW");
assertThat(service.get("invariantUUID")).isEqualTo("b58a118e-eeb9-4f6e-bdca-e292f84d17df");
- assertThat(service.get("toscaModelURL")).isEqualTo("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/toscaModel");
+ assertThat(service.get("toscaModelURL"))
+ .isEqualTo("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439/toscaModel");
assertThat(service.get("distributionStatus")).isEqualTo("DISTRIBUTED");
assertThat(service.get("version")).isEqualTo("2.0");
assertThat(service.get("lifecycleStatus")).isEqualTo("CERTIFIED");
@@ -47,7 +46,8 @@ public class ServiceCatalogAssertions {
if (serviceSPecCharacteristicMap.get("name").toString().equals("cpus")) {
assertThat(serviceSPecCharacteristicMap.get("valueType")).isEqualTo("integer");
assertThat(serviceSPecCharacteristicMap.get("@type")).isEqualTo("ONAPserviceCharacteristic");
- ArrayList serviceSpecCharacteristicValues = (ArrayList) serviceSPecCharacteristicMap.get("serviceSpecCharacteristicValue");
+ ArrayList serviceSpecCharacteristicValues =
+ (ArrayList) serviceSPecCharacteristicMap.get("serviceSpecCharacteristicValue");
for (Object serviceSpecCharacteristicValue : serviceSpecCharacteristicValues) {
LinkedHashMap serviceSpecCharacteristicValueMap = (LinkedHashMap) serviceSpecCharacteristicValue;
if (serviceSpecCharacteristicValueMap.get("value").toString().equals("2")) {
@@ -70,7 +70,8 @@ public class ServiceCatalogAssertions {
assertThat(service.get("id")).isEqualTo("1e3feeb0-8e36-46c6-862c-236d9c626439");
assertThat(service.get("name")).isEqualTo("vFW");
assertThat(service.get("invariantUUID")).isEqualTo("b58a118e-eeb9-4f6e-bdca-e292f84d17df");
- assertThat(service.get("toscaModelURL")).isEqualTo("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439toto/toscaModel");
+ assertThat(service.get("toscaModelURL"))
+ .isEqualTo("/sdc/v1/catalog/services/1e3feeb0-8e36-46c6-862c-236d9c626439toto/toscaModel");
assertThat(service.get("distributionStatus")).isEqualTo("DISTRIBUTED");
assertThat(service.get("version")).isEqualTo("2.0");
assertThat(service.get("lifecycleStatus")).isEqualTo("CERTIFIED");
@@ -95,7 +96,6 @@ public class ServiceCatalogAssertions {
-
public static void assertFindServiceCatalog(ResponseEntity<Object> resource) {
assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
ArrayList body = (ArrayList) resource.getBody();
diff --git a/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java
index e8afc9c..426b1a1 100644
--- a/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java
+++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java
@@ -1,22 +1,19 @@
-package org.onap.nbi.apis.resources;
+package org.onap.nbi.apis.assertions;
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();
+ 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");
@@ -25,13 +22,13 @@ public class ServiceInventoryAssertions {
LinkedHashMap relatedParty = (LinkedHashMap) service.get("relatedParty");
assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer");
assertThat(relatedParty.get("id")).isEqualTo("6490");
- LinkedHashMap serviceSpecification = (LinkedHashMap)service.get("serviceSpecification");
+ 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);
+ 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");
@@ -44,9 +41,9 @@ public class ServiceInventoryAssertions {
public static void assertServiceInventoryFind(ResponseEntity<Object> resource) {
assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
- ArrayList body = (ArrayList)resource.getBody();
+ ArrayList body = (ArrayList) resource.getBody();
assertThat(body.size()).isEqualTo(1);
- LinkedHashMap service1 = (LinkedHashMap)body.get(0);
+ 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");
@@ -60,9 +57,9 @@ public class ServiceInventoryAssertions {
public static void assertServiceInventoryFindWithoutParameter(ResponseEntity<Object> resource) {
assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
- ArrayList body = (ArrayList)resource.getBody();
+ ArrayList body = (ArrayList) resource.getBody();
assertThat(body.size()).isEqualTo(2);
- LinkedHashMap service1 = (LinkedHashMap)body.get(0);
+ 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");
@@ -73,7 +70,7 @@ public class ServiceInventoryAssertions {
assertThat(serviceSpecification.get("id")).isEqualTo("9vfw-service-modek-version-id");
- LinkedHashMap service2 = (LinkedHashMap)body.get(1);
+ 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");
diff --git a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java
new file mode 100644
index 0000000..2e89a8a
--- /dev/null
+++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java
@@ -0,0 +1,206 @@
+package org.onap.nbi.apis.assertions;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import org.onap.nbi.apis.serviceorder.model.ActionType;
+import org.onap.nbi.apis.serviceorder.model.OrderItemRelationship;
+import org.onap.nbi.apis.serviceorder.model.OrderRelationship;
+import org.onap.nbi.apis.serviceorder.model.RelatedParty;
+import org.onap.nbi.apis.serviceorder.model.Service;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
+import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
+import org.onap.nbi.apis.serviceorder.model.ServiceSpecificationRef;
+import org.onap.nbi.apis.serviceorder.model.StateType;
+import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson;
+import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderItemInfo;
+import org.onap.nbi.apis.serviceorder.repositories.ExecutionTaskRepository;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderInfoRepository;
+import org.onap.nbi.apis.serviceorder.repositories.ServiceOrderRepository;
+import org.onap.nbi.apis.serviceorder.utils.JsonEntityConverter;
+
+
+public class ServiceOrderAssertions {
+
+ public static ServiceOrder createTestServiceOrderRejected() {
+ ServiceOrder serviceOrder = new ServiceOrder();
+ serviceOrder.setExternalId("LudONAP001");
+ serviceOrder.setPriority("1");
+ serviceOrder.setDescription("Ludo first ONAP Order");
+ serviceOrder.setCategory("Consumer");
+ serviceOrder.setRequestedStartDate(new Date());
+ serviceOrder.setRequestedCompletionDate(new Date());
+
+ RelatedParty party = new RelatedParty();
+ party.setId("6490");
+ party.setRole("ONAPcustomer");
+ party.setReferredType("individual");
+ party.setName("Jean Pontus");
+ List<RelatedParty> relatedPartyList = new ArrayList<>();
+ relatedPartyList.add(party);
+ serviceOrder.setRelatedParty(relatedPartyList);
+
+ List<ServiceOrderItem> items = new ArrayList<>();
+
+ ServiceOrderItem itemA = new ServiceOrderItem();
+ itemA.id("A");
+ itemA.action(ActionType.ADD);
+ Service serviceA = new Service();
+ serviceA.setServiceState("active");
+ ServiceSpecificationRef serviceSpecificationRefA = new ServiceSpecificationRef();
+ serviceSpecificationRefA.setId("333");
+ serviceA.setServiceSpecification(serviceSpecificationRefA);
+ itemA.setService(serviceA);
+ items.add(itemA);
+
+ ServiceOrderItem itemB = new ServiceOrderItem();
+ itemB.id("B");
+ itemB.action(ActionType.ADD);
+ Service serviceB = new Service();
+ serviceB.setServiceState("active");
+ ServiceSpecificationRef serviceSpecificationRefB = new ServiceSpecificationRef();
+ serviceSpecificationRefB.setId("1e3feeb0-8e36-46c6-862c-236d9c626439");
+ serviceB.setServiceSpecification(serviceSpecificationRefB);
+ itemB.setService(serviceB);
+ List<OrderItemRelationship> orderItemRelationships = new ArrayList<>();
+ OrderItemRelationship orderItemRelationship = new OrderItemRelationship();
+ orderItemRelationship.setId("A");
+ orderItemRelationships.add(orderItemRelationship);
+ itemB.setOrderItemRelationship(orderItemRelationships);
+ items.add(itemB);
+ serviceOrder.setOrderItem(items);
+ return serviceOrder;
+
+ }
+
+
+ public static ServiceOrder createTestServiceOrder(ActionType actionType) {
+ ServiceOrder serviceOrder = new ServiceOrder();
+ serviceOrder.setExternalId("LudONAP001");
+ serviceOrder.setPriority("1");
+ serviceOrder.setDescription("Ludo first ONAP Order");
+ serviceOrder.setCategory("Consumer");
+ serviceOrder.setRequestedStartDate(new Date());
+ serviceOrder.setRequestedCompletionDate(new Date());
+ serviceOrder.setBaseType("toto");
+ serviceOrder.setCompletionDateTime(new Date());
+ serviceOrder.setExpectedCompletionDate(new Date());
+ serviceOrder.setSchemaLocation("/tutu");
+
+ OrderRelationship orderRelationship = new OrderRelationship();
+ orderRelationship.setId("test");
+ orderRelationship.setHref("test");
+ orderRelationship.setReferredType("test");
+ orderRelationship.setType("type");
+ List<OrderRelationship> relationships = new ArrayList<>();
+ serviceOrder.setOrderRelationship(relationships);
+
+ RelatedParty party = new RelatedParty();
+ party.setId("6490");
+ party.setRole("ONAPcustomer");
+ party.setReferredType("individual");
+ party.setName("Jean Pontus");
+ List<RelatedParty> relatedPartyList = new ArrayList<>();
+ relatedPartyList.add(party);
+ serviceOrder.setRelatedParty(relatedPartyList);
+
+ List<ServiceOrderItem> items = new ArrayList<>();
+
+ ServiceOrderItem itemA = new ServiceOrderItem();
+ itemA.id("A");
+ itemA.action(actionType);
+ Service serviceA = new Service();
+ if (actionType != ActionType.ADD) {
+ serviceA.setId("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb");
+ }
+ serviceA.setServiceState("active");
+ ServiceSpecificationRef serviceSpecificationRefA = new ServiceSpecificationRef();
+ serviceSpecificationRefA.setId("1e3feeb0-8e36-46c6-862c-236d9c626439");
+ serviceA.setServiceSpecification(serviceSpecificationRefA);
+ itemA.setService(serviceA);
+ items.add(itemA);
+
+ ServiceOrderItem itemB = new ServiceOrderItem();
+ itemB.id("B");
+ itemB.action(actionType);
+ Service serviceB = new Service();
+ if (actionType != ActionType.ADD) {
+ serviceB.setId("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb");
+ }
+ serviceB.setServiceState("active");
+ ServiceSpecificationRef serviceSpecificationRefB = new ServiceSpecificationRef();
+ serviceSpecificationRefB.setId("1e3feeb0-8e36-46c6-862c-236d9c626439");
+ serviceB.setServiceSpecification(serviceSpecificationRefB);
+ itemB.setService(serviceB);
+ List<OrderItemRelationship> orderItemRelationships = new ArrayList<>();
+ OrderItemRelationship orderItemRelationship = new OrderItemRelationship();
+ orderItemRelationship.setId("A");
+ orderItemRelationships.add(orderItemRelationship);
+ itemB.setOrderItemRelationship(orderItemRelationships);
+ items.add(itemB);
+ serviceOrder.setOrderItem(items);
+ return serviceOrder;
+
+ }
+
+
+ public static ExecutionTask setUpBddForExecutionTaskSucess(ServiceOrderRepository serviceOrderRepository,
+ ServiceOrderInfoRepository serviceOrderInfoRepository, ExecutionTaskRepository executionTaskRepository,
+ ActionType actionType) {
+ ServiceOrder testServiceOrder = createTestServiceOrder(actionType);
+
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.setState(StateType.ACKNOWLEDGED);
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ LinkedHashMap<String, String> sdcResponse = new LinkedHashMap<>();
+ sdcResponse.put("invariantUUID", "uuid");
+ sdcResponse.put("name", "vFW");
+ sdcResponse.put("version", "v1");
+
+ ServiceOrderInfo serviceOrderInfo = new ServiceOrderInfo();
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId("6490");
+ subscriberInfo.setSubscriberName("edgar");
+ serviceOrderInfo.setSubscriberInfo(subscriberInfo);
+
+ ServiceOrderItemInfo serviceOrderItemInfoA = new ServiceOrderItemInfo();
+ serviceOrderItemInfoA.setId("A");
+ serviceOrderItemInfoA.setCatalogResponse(sdcResponse);
+
+ ServiceOrderItemInfo serviceOrderItemInfoB = new ServiceOrderItemInfo();
+ serviceOrderItemInfoB.setId("B");
+ serviceOrderItemInfoB.setCatalogResponse(sdcResponse);
+ serviceOrderInfo.addServiceOrderItemInfos("A", serviceOrderItemInfoA);
+ serviceOrderInfo.addServiceOrderItemInfos("B", serviceOrderItemInfoB);
+
+ String json = JsonEntityConverter.convertServiceOrderInfoToJson(serviceOrderInfo);
+ ServiceOrderInfoJson serviceOrderInfoJson = new ServiceOrderInfoJson("test", json);
+ serviceOrderInfoRepository.save(serviceOrderInfoJson);
+
+ ExecutionTask executionTaskA = new ExecutionTask();
+ executionTaskA.setNbRetries(3);
+ executionTaskA.setOrderItemId("A");
+ executionTaskA.setServiceOrderInfoJson(serviceOrderInfoJson);
+ executionTaskA = executionTaskRepository.save(executionTaskA);
+ ExecutionTask executionTaskB = new ExecutionTask();
+ executionTaskB.setNbRetries(3);
+ executionTaskB.setOrderItemId("B");
+ executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId()));
+ executionTaskB.setServiceOrderInfoJson(serviceOrderInfoJson);
+ executionTaskRepository.save(executionTaskB);
+ return executionTaskA;
+ }
+
+
+
+}
diff --git a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java b/src/test/java/org/onap/nbi/apis/resources/ApiTest.java
deleted file mode 100644
index df2fb24..0000000
--- a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package org.onap.nbi.apis.resources;
-
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-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;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import com.github.tomakehurst.wiremock.WireMockServer;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-public class ApiTest {
-
- @LocalServerPort
- int randomServerPort;
-
- String realServerPort;
-
- static public WireMockServer wireMockServer = new WireMockServer(8091);
-
- @Autowired
- ServiceSpecificationResource serviceSpecificationResource;
-
- @Autowired
- ServiceInventoryResource serviceInventoryResource;
-
- @BeforeClass
- public static void setUp() throws Exception {
- wireMockServer.start();
- }
-
- @AfterClass
- public static void tearsDown() throws Exception {
- wireMockServer.stop();
-
- }
-
- @After
- public void tearsDownUpPort() throws Exception {
- wireMockServer.resetToDefaultMappings();
- }
-
- // serviceCatalog
-
- @Test
- @Ignore
- public void testServiceResourceGetCatalog() throws Exception {
-
- ResponseEntity<Object> resource =
- serviceSpecificationResource.getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439", null);
- ServiceCatalogAssertions.assertGetServiceCatalog(resource);
-
- }
-
- @Test
- public void testServiceCatalogGetResourceWithoutTosca() throws Exception {
-
- ResponseEntity<Object> resource = serviceSpecificationResource
- .getServiceSpecification("1e3feeb0-8e36-46c6-862c-236d9c626439_withoutTosca", null);
- ServiceCatalogAssertions.asserGetServiceCatalogWithoutTosca(resource);
-
- }
-
- @Test
- public void testServiceCatalogFind() throws Exception {
-
- ResponseEntity<Object> resource = serviceSpecificationResource.findServiceSpecification(null);
- ServiceCatalogAssertions.assertFindServiceCatalog(resource);
-
- }
-
-
- @Test
- public void testServiceCatalogFindWithFilter() throws Exception {
-
- MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
- params.add("fields", "name");
- ResponseEntity<Object> resource = serviceSpecificationResource.findServiceSpecification(params);
- ServiceCatalogAssertions.assertFindServiceCatalogWIthFilter(resource);
-
- }
-
- // 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);
-
- }
-
-}