aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authoraosull01 <adrian.osullivan@huawei.com>2018-08-13 14:49:43 +0100
committeraosull01 <adrian.osullivan@huawei.com>2018-08-21 12:36:52 +0100
commit0cff84e3ec149a17aad794fa1e7de0980a38807e (patch)
tree89d6b8f46c1b48538b29e07466d21d688374a0b1 /src/test/java/org
parent8bbefa2ea43f8d2beedeb347bb831b82009417a3 (diff)
EXTAPI-102 Initial commit
Issue-ID: EXTAPI-102 Change-Id: I8a24d9ea73ecfc9c386be12bd35f4d6141d6f2e9 Signed-off-by: aosull01 <adrian.osullivan@huawei.com> Co-authored-by: MariosIakovidis <marios.iakovidis@huawei.com> Co-authored-by: Prabhu201713 <Prabhu.balan1@vodafone.com>
Diffstat (limited to 'src/test/java/org')
-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
2 files changed, 214 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;
+ }
}