diff options
author | romaingimbert <romain.gimbert@orange.com> | 2018-05-03 10:11:19 +0200 |
---|---|---|
committer | romaingimbert <romain.gimbert@orange.com> | 2018-05-03 14:29:16 +0200 |
commit | a2a452f0539a7e9b50b2db0091481c37cf5c6589 (patch) | |
tree | b731a7e7b3fa13195776e91c1443fe08a553a9d5 /src/test | |
parent | 38bbb437d576643d450bc1fed0a20dfd93e45363 (diff) |
problem with when SO not responding
- fix infinite loop when SO not responding
- fix json with task
- fix infinite loop when no service found in SDC
Change-Id: Iddbf80a6c9bd99d0426c95d729b9f49440f1b945
Issue-ID: EXTAPI-80
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/nbi/apis/ApiTest.java | 136 | ||||
-rw-r--r-- | src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java | 14 |
2 files changed, 123 insertions, 27 deletions
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java index 937f417..ef285a4 100644 --- a/src/test/java/org/onap/nbi/apis/ApiTest.java +++ b/src/test/java/org/onap/nbi/apis/ApiTest.java @@ -44,7 +44,6 @@ 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; @@ -82,9 +81,6 @@ public class ApiTest { ServiceOrderRepository serviceOrderRepository; @Autowired - ServiceOrderInfoRepository serviceOrderInfoRepository; - - @Autowired ExecutionTaskRepository executionTaskRepository; @Autowired @@ -108,7 +104,6 @@ public class ApiTest { @After public void tearsDownUpPort() throws Exception { executionTaskRepository.deleteAll(); - serviceOrderInfoRepository.deleteAll(); serviceOrderRepository.deleteAll(); wireMockServer.resetToDefaultMappings(); @@ -125,6 +120,18 @@ public class ApiTest { return null; } + private void removeWireMockMapping(String s) { + ListStubMappingsResult listStubMappingsResult = wireMockServer.listAllStubMappings(); + StubMapping mappingToDelete = null; + List<StubMapping> mappings = listStubMappingsResult.getMappings(); + for (StubMapping mapping : mappings) { + if (mapping.getRequest().getUrl().equals(s)) { + mappingToDelete = mapping; + } + } + wireMockServer.removeStubMapping(mappingToDelete); + } + // serviceCatalog @Test @@ -308,7 +315,7 @@ public class ApiTest { } @Test - public void testCheckServiceOrderWithUnKnonwCustomer() throws Exception { + public void testCheckServiceOrderWithUnKnownCustomer() throws Exception { ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD); List<RelatedParty> customers = new ArrayList<>(); @@ -329,6 +336,57 @@ public class ApiTest { } + + @Test + public void testCheckServiceOrderWithCustomerAAINotResponding() throws Exception { + + removeWireMockMapping("/aai/v11/business/customers/customer/new"); + + 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.REJECTED); + + } + + + @Test + public void testCheckServiceOrderWithPutServiceAAINotResponding() throws Exception { + + removeWireMockMapping("/aai/v11/business/customers/customer/new/service-subscriptions/service-subscription/vFW"); + + 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.REJECTED); + + } + + @Test public void testCheckServiceOrderDelete() throws Exception { @@ -416,6 +474,30 @@ public class ApiTest { } + @Test + public void testCheckServiceOrderDeleteWithKoServiceSpecId() throws Exception { + + ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.DELETE); + for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) { + serviceOrderItem.getService().getServiceSpecification().setId("undefined"); + } + + testServiceOrder.setState(StateType.ACKNOWLEDGED); + testServiceOrder.setId("test"); + serviceOrderRepository.save(testServiceOrder); + + serviceOrderResource.scheduleCheckServiceOrders(); + + ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.REJECTED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + if (serviceOrderItem.getId().equals("A")) + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.REJECTED); + } + } + + + @Test public void testCheckServiceOrderRejected() throws Exception { @@ -512,7 +594,7 @@ public class ApiTest { public void testExecutionTaskSuccess() throws Exception { ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - serviceOrderInfoRepository, executionTaskRepository, ActionType.ADD); + executionTaskRepository, ActionType.ADD); ExecutionTask executionTaskB; @@ -551,7 +633,7 @@ public class ApiTest { public void testExecutionTaskDeleteSuccess() throws Exception { ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - serviceOrderInfoRepository, executionTaskRepository, ActionType.DELETE); + executionTaskRepository, ActionType.DELETE); ExecutionTask executionTaskB; @@ -590,17 +672,9 @@ public class ApiTest { public void testExecutionTaskFailed() throws Exception { ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - serviceOrderInfoRepository, executionTaskRepository, ActionType.ADD); + 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); + removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v4/requestId"); SoTaskProcessor.processOrderItem(executionTaskA); @@ -634,4 +708,30 @@ public class ApiTest { } + + + + @Test + public void testExecutionTaskFailedNoSoResponse() throws Exception { + + ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + + removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v4"); + + + 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); + } + + ExecutionTask executionTaskB = executionTaskRepository.findOne(Long.parseLong("2")); + assertThat(executionTaskB).isNull(); + + + } + + } 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 feec313..90fd852 100644 --- a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java +++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderAssertions.java @@ -31,10 +31,8 @@ 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; @@ -164,8 +162,8 @@ public class ServiceOrderAssertions { public static ExecutionTask setUpBddForExecutionTaskSucess(ServiceOrderRepository serviceOrderRepository, - ServiceOrderInfoRepository serviceOrderInfoRepository, ExecutionTaskRepository executionTaskRepository, - ActionType actionType) { + ExecutionTaskRepository executionTaskRepository, + ActionType actionType) { ServiceOrder testServiceOrder = createTestServiceOrder(actionType); for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) { @@ -182,7 +180,7 @@ public class ServiceOrderAssertions { sdcResponse.put("version", "v1"); ServiceOrderInfo serviceOrderInfo = new ServiceOrderInfo(); - + serviceOrderInfo.setServiceOrderId("test"); SubscriberInfo subscriberInfo = new SubscriberInfo(); subscriberInfo.setGlobalSubscriberId("6490"); subscriberInfo.setSubscriberName("edgar"); @@ -199,19 +197,17 @@ public class ServiceOrderAssertions { 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.setServiceOrderInfoJson(json); executionTaskA = executionTaskRepository.save(executionTaskA); ExecutionTask executionTaskB = new ExecutionTask(); executionTaskB.setNbRetries(3); executionTaskB.setOrderItemId("B"); executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); - executionTaskB.setServiceOrderInfoJson(serviceOrderInfoJson); + executionTaskB.setServiceOrderInfoJson(json); executionTaskRepository.save(executionTaskB); return executionTaskA; } |