aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorMatthieu Geerebaert <matthieu.geerebaert@orange.com>2018-08-21 12:58:42 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-21 12:58:42 +0000
commit9feae3a717ad1fc69700e59f7b3181fa78337138 (patch)
tree0cac4f53d3583d755471d0e4266e8762161f50a5 /src/test
parent9258c8f5f392ff86d3aea73f3ab078ae4c796258 (diff)
parent0cff84e3ec149a17aad794fa1e7de0980a38807e (diff)
Merge "EXTAPI-102 Initial commit"
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTest.java133
-rw-r--r--src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java81
-rw-r--r--src/test/resources/mappings/so_e2e_delete_service_instance.json15
-rw-r--r--src/test/resources/mappings/so_get_e2e.json25
-rw-r--r--src/test/resources/mappings/so_get_e2e_delete.json25
-rw-r--r--src/test/resources/mappings/so_post_e2e_create_service_instance.json18
6 files changed, 297 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 033f3be..f18c5f8 100644
--- a/src/test/java/org/onap/nbi/apis/ApiTest.java
+++ b/src/test/java/org/onap/nbi/apis/ApiTest.java
@@ -776,6 +776,43 @@ public class ApiTest {
}
+ @Test
+ public void testE2EExecutionTaskSuccess() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository,
+ 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);
+
+ }
+
+ assertThat(executionTaskRepository.count()).isEqualTo(0);
+
+
+
+ }
@Test
public void testExecutionTaskDeleteSuccess() throws Exception {
@@ -815,6 +852,44 @@ public class ApiTest {
}
+ @Test
+ public void testE2EExecutionTaskDeleteSuccess() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository,
+ 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);
+
+ }
+
+ assertThat(executionTaskRepository.count()).isEqualTo(0);
+
+
+
+ }
+
@Test
public void testExecutionTaskFailed() throws Exception {
@@ -856,8 +931,45 @@ public class ApiTest {
}
+ @Test
+ public void testE2EExecutionTaskFailed() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository,
+ executionTaskRepository, ActionType.ADD);
+
+ removeWireMockMapping("/ecomp/mso/infra/e2eServiceInstances/v3/serviceId/operations/operationId");
+
+
+ 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);
+
+ }
+
+ assertThat(executionTaskRepository.count()).isEqualTo(0);
+ }
+
@Test
public void testExecutionTaskFailedNoSoResponse() throws Exception {
@@ -900,4 +1012,25 @@ public class ApiTest {
assertThat(executionTaskRepository.count()).isEqualTo(0);
}
+
+ @Test
+ public void testE2EExecutionTaskFailedNoSoAndStatusResponse() throws Exception {
+
+ ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository,
+ executionTaskRepository, ActionType.ADD);
+
+ removeWireMockMapping("/ecomp/mso/infra/e2eServiceInstances/v3");
+ removeWireMockMapping("/ecomp/mso/infra/e2eServiceInstances/v3/serviceId/operations/operationId");
+
+
+ SoTaskProcessor.processOrderItem(executionTaskA);
+ ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+ assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED);
+ for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) {
+ assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED);
+ }
+
+ assertThat(executionTaskRepository.count()).isEqualTo(0);
+
+ }
}
diff --git a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java
index 90fd852..65686d2 100644
--- a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java
+++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java
@@ -23,11 +23,14 @@ 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.ResourceSpecification;
import org.onap.nbi.apis.serviceorder.model.Service;
+import org.onap.nbi.apis.serviceorder.model.ServiceCharacteristic;
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.Value;
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;
@@ -178,6 +181,7 @@ public class ServiceOrderAssertions {
sdcResponse.put("invariantUUID", "uuid");
sdcResponse.put("name", "vFW");
sdcResponse.put("version", "v1");
+ sdcResponse.put("category", "NonE2E");
ServiceOrderInfo serviceOrderInfo = new ServiceOrderInfo();
serviceOrderInfo.setServiceOrderId("test");
@@ -212,6 +216,83 @@ public class ServiceOrderAssertions {
return executionTaskA;
}
+ public static ExecutionTask setUpBddForE2EExecutionTaskSucess(ServiceOrderRepository serviceOrderRepository,
+ ExecutionTaskRepository executionTaskRepository,
+ ActionType actionType) {
+ ServiceOrder testServiceOrder = createTestServiceOrder(actionType);
+
+ for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) {
+ serviceOrderItem.setState(StateType.ACKNOWLEDGED);
+ List<ServiceCharacteristic> serviceCharacteristics = new ArrayList();
+ ServiceCharacteristic serviceCharacteristic1 = new ServiceCharacteristic();
+ serviceCharacteristic1.setName("access-site-id");
+ Value value1 = new Value();
+ value1.setServiceCharacteristicValue("1234765");
+ serviceCharacteristic1.setValue(value1);
+ serviceCharacteristics.add(serviceCharacteristic1);
+ ServiceCharacteristic serviceCharacteristic2 = new ServiceCharacteristic();
+ serviceCharacteristic2.setName("provider-site-id");
+ Value value2 = new Value();
+ value2.setServiceCharacteristicValue("654321");
+ serviceCharacteristic2.setValue(value2);
+ serviceCharacteristics.add(serviceCharacteristic2);
+ serviceOrderItem.getService().setServiceCharacteristic(serviceCharacteristics);
+ }
+
+ testServiceOrder.setState(StateType.ACKNOWLEDGED);
+ testServiceOrder.setId("test");
+ serviceOrderRepository.save(testServiceOrder);
+
+ LinkedHashMap<String, Object> sdcResponse = new LinkedHashMap<>();
+ sdcResponse.put("invariantUUID", "uuid");
+ sdcResponse.put("name", "vFW");
+ sdcResponse.put("version", "v1");
+ sdcResponse.put("category", "E2E Service");
+
+ List<ResourceSpecification> resourceSpecs = new ArrayList<>();
+ ResourceSpecification resourceSpecificationA = new ResourceSpecification();
+ resourceSpecificationA.setId("2e3feeb0-8e36-46c6-862c-236d9c626438");
+ resourceSpecificationA.setInstanceName("vFW-vSINK");
+ resourceSpecificationA.setName("vFW-SINK");
+ resourceSpecificationA.setType("ONAPresource");
+ resourceSpecificationA.setVersion("2.0");
+ resourceSpecificationA.setResourceInvariantUUID("6e3feeb0-8e36-46c6-862c-236d9c626438");
+ resourceSpecs.add(resourceSpecificationA);
+
+ sdcResponse.put("resourceSpecification", resourceSpecs );
+
+ ServiceOrderInfo serviceOrderInfo = new ServiceOrderInfo();
+ serviceOrderInfo.setServiceOrderId("test");
+ 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);
+
+ ExecutionTask executionTaskA = new ExecutionTask();
+ executionTaskA.setNbRetries(3);
+ executionTaskA.setOrderItemId("A");
+ executionTaskA.setServiceOrderInfoJson(json);
+ executionTaskA = executionTaskRepository.save(executionTaskA);
+ ExecutionTask executionTaskB = new ExecutionTask();
+ executionTaskB.setNbRetries(3);
+ executionTaskB.setOrderItemId("B");
+ executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId()));
+ executionTaskB.setServiceOrderInfoJson(json);
+ executionTaskRepository.save(executionTaskB);
+ return executionTaskA;
+ }
}
diff --git a/src/test/resources/mappings/so_e2e_delete_service_instance.json b/src/test/resources/mappings/so_e2e_delete_service_instance.json
new file mode 100644
index 0000000..0b0615c
--- /dev/null
+++ b/src/test/resources/mappings/so_e2e_delete_service_instance.json
@@ -0,0 +1,15 @@
+{
+ "request": {
+ "method": "DELETE",
+ "url": "/ecomp/mso/infra/e2eServiceInstances/v3/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"
+ },
+ "response": {
+ "status": 202,
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "jsonBody": {
+ "operationId": "operationId"
+ }
+ }
+}
diff --git a/src/test/resources/mappings/so_get_e2e.json b/src/test/resources/mappings/so_get_e2e.json
new file mode 100644
index 0000000..e3bb36e
--- /dev/null
+++ b/src/test/resources/mappings/so_get_e2e.json
@@ -0,0 +1,25 @@
+{
+"request": {
+ "method": "GET",
+ "url": "/ecomp/mso/infra/e2eServiceInstances/v3/serviceId/operations/operationId"
+ },
+ "response": {
+ "status": 200,
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "jsonBody": {
+ "operation": {
+ "operationId": "operationid",
+ "operation": "create",
+ "result": "finished",
+ "reason": "",
+ "userid": "",
+ "operationContent": "Creating E2E SOTN Service",
+ "progress": 100,
+ "operateAt": "",
+ "finishedAt": ""
+ }
+ }
+ }
+}
diff --git a/src/test/resources/mappings/so_get_e2e_delete.json b/src/test/resources/mappings/so_get_e2e_delete.json
new file mode 100644
index 0000000..f6bc117
--- /dev/null
+++ b/src/test/resources/mappings/so_get_e2e_delete.json
@@ -0,0 +1,25 @@
+{
+ "request": {
+ "method": "GET",
+ "url": "/ecomp/mso/infra/e2eServiceInstances/v3/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb/operations/operationId"
+ },
+ "response": {
+ "status": 200,
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "jsonBody": {
+ "operation": {
+ "operationId": "operationid",
+ "operation": "create",
+ "result": "finished",
+ "reason": "",
+ "userid": "",
+ "operationContent": "Creating E2E SOTN Service",
+ "progress": 100,
+ "operateAt": "",
+ "finishedAt": ""
+ }
+ }
+ }
+}
diff --git a/src/test/resources/mappings/so_post_e2e_create_service_instance.json b/src/test/resources/mappings/so_post_e2e_create_service_instance.json
new file mode 100644
index 0000000..a5b7cce
--- /dev/null
+++ b/src/test/resources/mappings/so_post_e2e_create_service_instance.json
@@ -0,0 +1,18 @@
+{
+ "request": {
+ "method": "POST",
+ "url": "/ecomp/mso/infra/e2eServiceInstances/v3"
+ },
+ "response": {
+ "status": 201,
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "jsonBody": {
+ "service": {
+ "serviceId": "serviceId",
+ "operationId": "operationId"
+ }
+ }
+ }
+}