diff options
author | aosull01 <adrian.osullivan@huawei.com> | 2019-10-15 14:15:46 +0100 |
---|---|---|
committer | aosull01 <adrian.osullivan@huawei.com> | 2019-10-15 14:38:21 +0100 |
commit | 297bacd11441130e2f08636c415c561e2f59d607 (patch) | |
tree | a5e2ea6ad73f87e1833fb45a2f3947777d6c06c9 /src/test | |
parent | ab38dd33bc35ae61fc40d5c4a090a21cb214078c (diff) |
Add support for object characteristic type in Service Order
Change-Id: I36d30f8f4e38400d594215fce2a54a3beea77f2c
Issue-ID: EXTAPI-294
Signed-off-by: aosull01 <adrian.osullivan@huawei.com>
Diffstat (limited to 'src/test')
4 files changed, 902 insertions, 656 deletions
diff --git a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderExecutionTaskAssertions.java b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderExecutionTaskAssertions.java index 6fea745..5dc261a 100644 --- a/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderExecutionTaskAssertions.java +++ b/src/test/java/org/onap/nbi/apis/assertions/ServiceOrderExecutionTaskAssertions.java @@ -1,17 +1,15 @@ /** - * Copyright (c) 2018 Orange + * Copyright (c) 2018 Orange * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.onap.nbi.apis.assertions; @@ -43,258 +41,404 @@ import org.onap.nbi.apis.serviceorder.utils.JsonEntityConverter; public class ServiceOrderExecutionTaskAssertions { - 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 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"); } - - - 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"); - orderItemRelationship.setType(RelationshipType.RELIESON); - orderItemRelationships.add(orderItemRelationship); - itemB.setOrderItemRelationship(orderItemRelationships); - items.add(itemB); - serviceOrder.setOrderItem(items); - return serviceOrder; - + 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"); + orderItemRelationship.setType(RelationshipType.RELIESON); + orderItemRelationships.add(orderItemRelationship); + itemB.setOrderItemRelationship(orderItemRelationships); + items.add(itemB); + serviceOrder.setOrderItem(items); + return serviceOrder; + + } + + + public static ExecutionTask setUpBddForExecutionTaskSucess( + ServiceOrderRepository serviceOrderRepository, + ExecutionTaskRepository executionTaskRepository, ActionType actionType) { + ServiceOrder testServiceOrder = createTestServiceOrder(actionType); + + for (ServiceOrderItem serviceOrderItem : testServiceOrder.getOrderItem()) { + serviceOrderItem.setState(StateType.ACKNOWLEDGED); } - - public static ExecutionTask setUpBddForExecutionTaskSucess(ServiceOrderRepository serviceOrderRepository, - 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"); - sdcResponse.put("category", "NonE2E"); - - 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.setCreateDate(new Date()); - executionTaskA.setOrderItemId("A"); - executionTaskA.setServiceOrderInfoJson(json); - executionTaskA = executionTaskRepository.save(executionTaskA); - ExecutionTask executionTaskB = new ExecutionTask(); - executionTaskB.setCreateDate(new Date()); - executionTaskB.setOrderItemId("B"); - executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); - executionTaskB.setServiceOrderInfoJson(json); - executionTaskRepository.save(executionTaskB); - return executionTaskA; + 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"); + sdcResponse.put("category", "NonE2E"); + + 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.setCreateDate(new Date()); + executionTaskA.setOrderItemId("A"); + executionTaskA.setServiceOrderInfoJson(json); + executionTaskA = executionTaskRepository.save(executionTaskA); + ExecutionTask executionTaskB = new ExecutionTask(); + executionTaskB.setCreateDate(new Date()); + executionTaskB.setOrderItemId("B"); + executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); + executionTaskB.setServiceOrderInfoJson(json); + executionTaskRepository.save(executionTaskB); + 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); } - 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.setCreateDate(new Date()); - executionTaskA.setOrderItemId("A"); - executionTaskA.setServiceOrderInfoJson(json); - executionTaskA = executionTaskRepository.save(executionTaskA); - ExecutionTask executionTaskB = new ExecutionTask(); - executionTaskB.setCreateDate(new Date()); - executionTaskB.setOrderItemId("B"); - executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); - executionTaskB.setServiceOrderInfoJson(json); - executionTaskRepository.save(executionTaskB); - return executionTaskA; - } + 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.setCreateDate(new Date()); + executionTaskA.setOrderItemId("A"); + executionTaskA.setServiceOrderInfoJson(json); + executionTaskA = executionTaskRepository.save(executionTaskA); + ExecutionTask executionTaskB = new ExecutionTask(); + executionTaskB.setCreateDate(new Date()); + executionTaskB.setOrderItemId("B"); + executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); + executionTaskB.setServiceOrderInfoJson(json); + executionTaskRepository.save(executionTaskB); + return executionTaskA; + } + + public static ExecutionTask setUpBddForE2EExecutionTaskSucessWithObject( + 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("EPL_ServiceCharacteristics"); + serviceCharacteristic1.setValueType("object"); + Value value1 = new Value(); + value1.setServiceCharacteristicValue("{ \"key1\":\"value1\", \"key2\":\"value2\"}"); + serviceCharacteristic1.setValue(value1); + serviceCharacteristics.add(serviceCharacteristic1); + 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.setCreateDate(new Date()); + executionTaskA.setOrderItemId("A"); + executionTaskA.setServiceOrderInfoJson(json); + executionTaskA = executionTaskRepository.save(executionTaskA); + ExecutionTask executionTaskB = new ExecutionTask(); + executionTaskB.setCreateDate(new Date()); + executionTaskB.setOrderItemId("B"); + executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); + executionTaskB.setServiceOrderInfoJson(json); + executionTaskRepository.save(executionTaskB); + return executionTaskA; + } + + public static ExecutionTask setUpBddForE2EExecutionTaskSucessWithComplexObject( + 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("EPL_ServiceCharacteristics"); + serviceCharacteristic1.setValueType("object"); + Value value1 = new Value(); + // Three parameters , one is an array of child objects + value1.setServiceCharacteristicValue( + "{\"key1\":\"value1\", \"key2\":\"value2\", \"key3\":[ {\"lat1\":\"value1\",\"lon1\":\"value1\"}, { \"lat2\":\"value2\", \"lon2\":\"value2\"}]}"); + serviceCharacteristic1.setValue(value1); + serviceCharacteristics.add(serviceCharacteristic1); + 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.setCreateDate(new Date()); + executionTaskA.setOrderItemId("A"); + executionTaskA.setServiceOrderInfoJson(json); + executionTaskA = executionTaskRepository.save(executionTaskA); + ExecutionTask executionTaskB = new ExecutionTask(); + executionTaskB.setCreateDate(new Date()); + executionTaskB.setOrderItemId("B"); + executionTaskB.setReliedTasks(String.valueOf(executionTaskA.getInternalId())); + executionTaskB.setServiceOrderInfoJson(json); + executionTaskRepository.save(executionTaskB); + return executionTaskA; + } } diff --git a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java index 68a955f..0043a8a 100644 --- a/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java +++ b/src/test/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessorTest.java @@ -23,13 +23,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.nbi.exceptions.TechnicalException; import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; @RunWith(SpringRunner.class) @@ -48,7 +48,7 @@ public class ToscaInfosProcessorTest { ClassLoader classLoader = getClass().getClassLoader(); Path path = new File( - classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()) + classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()) .toPath().toAbsolutePath(); List<LinkedHashMap> resources = new ArrayList<>(); LinkedHashMap resource1 = new LinkedHashMap(); @@ -64,22 +64,22 @@ public class ToscaInfosProcessorTest { toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response); } catch (SdcToscaParserException e) { throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " - + path.toString() + " " + e.getMessage()); + + path.toString() + " " + e.getMessage()); } resources = (List<LinkedHashMap>) response.get("resourceSpecification"); List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>(); serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic"); assertThat(serviceSpecCharacteristic.get(0).get("name")) - .isEqualTo("sdwanconnectivity0_topology"); + .isEqualTo("sdwanconnectivity0_topology"); assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string"); assertThat(serviceSpecCharacteristic.get(0).get("required")).isEqualTo(true); assertThat(serviceSpecCharacteristic.get(1).get("name")).isEqualTo("sdwanconnectivity0_name"); assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string"); assertThat(serviceSpecCharacteristic.get(1).get("required")).isEqualTo(true); assertThat(resources.get(0).get("modelCustomizationId")) - .isEqualTo("94ec574b-2306-4cbd-8214-09662b040f73"); + .isEqualTo("94ec574b-2306-4cbd-8214-09662b040f73"); assertThat(resources.get(1).get("modelCustomizationId")) - .isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1"); + .isEqualTo("a7baba5d-6ac3-42b5-b47d-070841303ab1"); } @@ -88,7 +88,7 @@ public class ToscaInfosProcessorTest { ClassLoader classLoader = getClass().getClassLoader(); Path path = new File( - classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()) + classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()) .toPath().toAbsolutePath(); List<LinkedHashMap> resources = new ArrayList<>(); LinkedHashMap resource1 = new LinkedHashMap(); @@ -104,15 +104,15 @@ public class ToscaInfosProcessorTest { toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response); } catch (SdcToscaParserException e) { throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " - + path.toString() + " " + e.getMessage()); + + path.toString() + " " + e.getMessage()); } resources = (List<LinkedHashMap>) response.get("resourceSpecification"); List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>(); serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic"); assertThat(resources.get(0).get("modelCustomizationId")) - .isEqualTo("b44071c8-04fd-4d6b-b6af-772cbfaa1129"); + .isEqualTo("b44071c8-04fd-4d6b-b6af-772cbfaa1129"); assertThat(resources.get(1).get("modelCustomizationId")) - .isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d"); + .isEqualTo("c3612284-6c67-4d8c-8b41-b699cc90e76d"); assertThat(serviceSpecCharacteristic.get(12).get("serviceSpecCharacteristicValue")).isNull(); assertThat(serviceSpecCharacteristic.get(13).get("serviceSpecCharacteristicValue")).isNotNull(); } @@ -122,7 +122,7 @@ public class ToscaInfosProcessorTest { ClassLoader classLoader = getClass().getClassLoader(); Path path = new File( - classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()) + classLoader.getResource("toscafile/service-Sdwanvpninfraservice-csar.csar").getFile()) .toPath().toAbsolutePath(); List<LinkedHashMap> resources = new ArrayList<>(); LinkedHashMap resource1 = new LinkedHashMap(); @@ -138,13 +138,13 @@ public class ToscaInfosProcessorTest { toscaInfosProcessor.buildResponseWithSdcToscaParser(path, response); } catch (SdcToscaParserException e) { throw new TechnicalException("unable to build response from tosca csar using sdc-parser : " - + path.toString() + " " + e.getMessage()); + + path.toString() + " " + e.getMessage()); } resources = (List<LinkedHashMap>) response.get("resourceSpecification"); List<LinkedHashMap> serviceSpecCharacteristic = new ArrayList<>(); serviceSpecCharacteristic = (List<LinkedHashMap>) response.get("serviceSpecCharacteristic"); assertThat(serviceSpecCharacteristic.get(0).get("name")) - .isEqualTo("sdwanconnectivity0_topology"); + .isEqualTo("sdwanconnectivity0_topology"); assertThat(serviceSpecCharacteristic.get(1).get("valueType")).isEqualTo("string"); assertThat(serviceSpecCharacteristic.get(0).get("required")).isEqualTo(true); assertThat(serviceSpecCharacteristic.get(1).get("name")).isEqualTo("sdwanconnectivity0_name"); @@ -160,7 +160,9 @@ public class ToscaInfosProcessorTest { public void testBuildAndSaveResponseWithSdcToscaParser() { ClassLoader classLoader = getClass().getClassLoader(); - Path path = new File(classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()).toPath().toAbsolutePath(); + Path path = new File( + classLoader.getResource("toscafile/service-Sotnvpninfraservice-csar.csar").getFile()) + .toPath().toAbsolutePath(); LinkedHashMap response = new LinkedHashMap(); response.put("version", "1.0"); @@ -179,17 +181,20 @@ public class ToscaInfosProcessorTest { response.put("resourceSpecification", resources); LinkedHashMap serviceSpecCharacteristicValue = new LinkedHashMap(); - serviceSpecCharacteristicValue.put("valueType","Object"); - serviceSpecCharacteristicValue.put("@schemaLocation","/serviceSpecification/7f5e5139-768d-4410-a871-c41430785214/specificationInputSchema"); - serviceSpecCharacteristicValue.put("@type","Service_vMME_ServiceCharacteristic"); + serviceSpecCharacteristicValue.put("valueType", "object"); + serviceSpecCharacteristicValue.put("@schemaLocation", + "/serviceSpecification/7f5e5139-768d-4410-a871-c41430785214/specificationInputSchema"); + serviceSpecCharacteristicValue.put("@type", "Service_vMME_ServiceCharacteristic"); LinkedHashMap serviceSpecCharacteristic = new LinkedHashMap(); - serviceSpecCharacteristic.put("name","Service_vMME_ServiceCharacteristics"); - serviceSpecCharacteristic.put("description", "This object describes all the inputs needed from the client to interact with the Service_vMME Service Topology"); - serviceSpecCharacteristic.put("valueType","Object"); - serviceSpecCharacteristic.put("@type","ONAPServiceCharacteristic"); - serviceSpecCharacteristic.put("@schemaLocation","null"); - serviceSpecCharacteristic.put("serviceSpecCharacteristicValue",serviceSpecCharacteristicValue); + serviceSpecCharacteristic.put("name", "Service_vMME_ServiceCharacteristics"); + serviceSpecCharacteristic.put("description", + "This object describes all the inputs needed from the client to interact with the Service_vMME Service Topology"); + // using object to match examples in specifications + serviceSpecCharacteristic.put("valueType", "object"); + serviceSpecCharacteristic.put("@type", "ONAPServiceCharacteristic"); + serviceSpecCharacteristic.put("@schemaLocation", "null"); + serviceSpecCharacteristic.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValue); try { toscaInfosProcessor.buildAndSaveResponseWithSdcToscaParser(path, response); } catch (SdcToscaParserException ex) { diff --git a/src/test/java/org/onap/nbi/test/ExecutionTaskTest.java b/src/test/java/org/onap/nbi/test/ExecutionTaskTest.java index 7bc8a41..4d32672 100644 --- a/src/test/java/org/onap/nbi/test/ExecutionTaskTest.java +++ b/src/test/java/org/onap/nbi/test/ExecutionTaskTest.java @@ -1,26 +1,20 @@ /** - * Copyright (c) 2018 Orange + * Copyright (c) 2018 Orange * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.onap.nbi.test; import static org.assertj.core.api.Assertions.assertThat; - -import com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; -import com.github.tomakehurst.wiremock.stubbing.StubMapping; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -52,522 +46,625 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import com.github.tomakehurst.wiremock.admin.model.ListStubMappingsResult; +import com.github.tomakehurst.wiremock.http.ResponseDefinition; +import com.github.tomakehurst.wiremock.stubbing.StubMapping; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ActiveProfiles("test") -@DirtiesContext(classMode= ClassMode.AFTER_CLASS) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class ExecutionTaskTest { - @Autowired - ServiceOrderRepository serviceOrderRepository; + @Autowired + ServiceOrderRepository serviceOrderRepository; - @Autowired - ExecutionTaskRepository executionTaskRepository; + @Autowired + ExecutionTaskRepository executionTaskRepository; - @Autowired - SOTaskProcessor SoTaskProcessor; + @Autowired + SOTaskProcessor SoTaskProcessor; - static Validator validator; + static Validator validator; - @Before - public void before() { - MockHttpServletRequest request = new MockHttpServletRequest(); - RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); - } + @Before + public void before() { + MockHttpServletRequest request = new MockHttpServletRequest(); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + } - @BeforeClass - public static void setUp() throws Exception { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); - validator = factory.getValidator(); - Context.startWiremock(); - } + @BeforeClass + public static void setUp() throws Exception { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + validator = factory.getValidator(); + Context.startWiremock(); + } - @AfterClass - public static void tearsDown() throws Exception { - Context.stopServers(); + @AfterClass + public static void tearsDown() throws Exception { + Context.stopServers(); - } + } - @After - public void tearsDownUpPort() throws Exception { - executionTaskRepository.deleteAll(); - serviceOrderRepository.deleteAll(); - Context.wireMockServer.resetToDefaultMappings(); + @After + public void tearsDownUpPort() throws Exception { + executionTaskRepository.deleteAll(); + serviceOrderRepository.deleteAll(); + Context.wireMockServer.resetToDefaultMappings(); - } + } - public ExecutionTask getExecutionTask(String orderItemId) { - for (ExecutionTask executionTask : executionTaskRepository.findAll()) { - if (executionTask.getOrderItemId().equalsIgnoreCase(orderItemId)) { - return executionTask; - } + public ExecutionTask getExecutionTask(String orderItemId) { + for (ExecutionTask executionTask : executionTaskRepository.findAll()) { + if (executionTask.getOrderItemId().equalsIgnoreCase(orderItemId)) { + return executionTask; + } - } - return null; } - - private void changeWireMockResponse(String s,int statusCode, String bodyContent) { - ListStubMappingsResult listStubMappingsResult = Context.wireMockServer.listAllStubMappings(); - ResponseDefinition responseDefinition = new ResponseDefinition(statusCode,bodyContent); - List<StubMapping> mappings = listStubMappingsResult.getMappings(); - for (StubMapping mapping : mappings) { - if (mapping.getRequest().getUrl().equals(s)) { - mapping.setResponse(responseDefinition); - } - } + return null; + } + + private void changeWireMockResponse(String s, int statusCode, String bodyContent) { + ListStubMappingsResult listStubMappingsResult = Context.wireMockServer.listAllStubMappings(); + ResponseDefinition responseDefinition = new ResponseDefinition(statusCode, bodyContent); + List<StubMapping> mappings = listStubMappingsResult.getMappings(); + for (StubMapping mapping : mappings) { + if (mapping.getRequest().getUrl().equals(s)) { + mapping.setResponse(responseDefinition); + } } + } - private ServiceOrder getServiceOrder(String serviceOrderId) { - Optional<ServiceOrder> serviceOrderChecked = serviceOrderRepository.findById(serviceOrderId); - return serviceOrderChecked.get(); - } + private ServiceOrder getServiceOrder(String serviceOrderId) { + Optional<ServiceOrder> serviceOrderChecked = serviceOrderRepository.findById(serviceOrderId); + return serviceOrderChecked.get(); + } - @Test - public void testExecutionTaskSuccess() throws Exception { + @Test + public void testExecutionTaskSuccess() throws Exception { - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, executionTaskRepository, ActionType.ADD); - ExecutionTask executionTaskB; + ExecutionTask executionTaskB; + + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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 = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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); - } - } + assertThat(executionTaskRepository.count()).isEqualTo(0); - executionTaskB = getExecutionTask("B"); - assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty(); - executionTaskA = getExecutionTask("A"); - assertThat(executionTaskA).isNull(); - SoTaskProcessor.processOrderItem(executionTaskB); - serviceOrderChecked = getServiceOrder("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 testE2EExecutionTaskSuccess() throws Exception { + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess( + serviceOrderRepository, executionTaskRepository, ActionType.ADD); + ExecutionTask executionTaskB; + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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); + } } - @Test - public void testE2EExecutionTaskSuccess() throws Exception { + executionTaskB = getExecutionTask("B"); + assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty(); + executionTaskA = getExecutionTask("A"); + assertThat(executionTaskA).isNull(); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); - ExecutionTask executionTaskB; + SoTaskProcessor.processOrderItem(executionTaskB); + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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); - } - } + assertThat(executionTaskRepository.count()).isEqualTo(0); - executionTaskB = getExecutionTask("B"); - assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty(); - executionTaskA = getExecutionTask("A"); - assertThat(executionTaskA).isNull(); - SoTaskProcessor.processOrderItem(executionTaskB); - serviceOrderChecked = getServiceOrder("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 testE2EExecutionTaskSuccessWithObject() throws Exception { + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucessWithObject( + serviceOrderRepository, executionTaskRepository, ActionType.ADD); + ExecutionTask executionTaskB; + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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); + } } - @Test - public void testExecutionTaskDeleteSuccess() throws Exception { + executionTaskB = getExecutionTask("B"); + assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty(); + executionTaskA = getExecutionTask("A"); + assertThat(executionTaskA).isNull(); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.DELETE); - ExecutionTask executionTaskB; + SoTaskProcessor.processOrderItem(executionTaskB); + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); + } + + assertThat(executionTaskRepository.count()).isEqualTo(0); - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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 = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); + } - } + @Test + public void testE2EExecutionTaskSuccessWithComplexObject() throws Exception { + // A Service Order with complex object including arrays + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucessWithComplexObject( + serviceOrderRepository, executionTaskRepository, ActionType.ADD); + ExecutionTask executionTaskB; - assertThat(executionTaskRepository.count()).isEqualTo(0); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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 = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); } - @Test - public void testE2EExecutionTaskDeleteSuccess() throws Exception { + assertThat(executionTaskRepository.count()).isEqualTo(0); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository, + + + } + + @Test + public void testExecutionTaskDeleteSuccess() throws Exception { + + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, executionTaskRepository, ActionType.DELETE); - ExecutionTask executionTaskB; + ExecutionTask executionTaskB; + + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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 = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); + + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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); - } - } + assertThat(executionTaskRepository.count()).isEqualTo(0); - executionTaskB = getExecutionTask("B"); - assertThat(executionTaskB.getReliedTasks()).isNullOrEmpty(); - executionTaskA = getExecutionTask("A"); - assertThat(executionTaskA).isNull(); - SoTaskProcessor.processOrderItem(executionTaskB); - serviceOrderChecked = getServiceOrder("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 testE2EExecutionTaskDeleteSuccess() throws Exception { + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess( + serviceOrderRepository, executionTaskRepository, ActionType.DELETE); + ExecutionTask executionTaskB; + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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(); - @Test - public void testExecutionTaskFailed() throws Exception { + SoTaskProcessor.processOrderItem(executionTaskB); + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); + } - Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); + assertThat(executionTaskRepository.count()).isEqualTo(0); - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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"); - Date createDate = executionTaskA.getCreateDate(); - assertThat(executionTaskA.getLastAttemptDate().getTime()> createDate.getTime()).isTrue(); - changeCreationDate(executionTaskA); - SoTaskProcessor.processOrderItem(executionTaskA); + } - serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } + @Test + public void testExecutionTaskFailed() throws Exception { - assertThat(executionTaskRepository.count()).isEqualTo(0); + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); - } - private void changeCreationDate(ExecutionTask executionTaskA) { - Calendar cal = Calendar.getInstance(); - cal.setTime(executionTaskA.getCreateDate()); - cal.add(Calendar.SECOND, -30); - executionTaskA.setCreateDate(cal.getTime()); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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"); + Date createDate = executionTaskA.getCreateDate(); + assertThat(executionTaskA.getLastAttemptDate().getTime() > createDate.getTime()).isTrue(); + changeCreationDate(executionTaskA); + SoTaskProcessor.processOrderItem(executionTaskA); - @Test - public void testE2EExecutionTaskFailed() throws Exception { + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); + + } + + assertThat(executionTaskRepository.count()).isEqualTo(0); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); - Context.removeWireMockMapping("/onap/so/infra/e2eServiceInstances/v3/serviceId/operations/operationId"); + } + private void changeCreationDate(ExecutionTask executionTaskA) { + Calendar cal = Calendar.getInstance(); + cal.setTime(executionTaskA.getCreateDate()); + cal.add(Calendar.SECOND, -30); + executionTaskA.setCreateDate(cal.getTime()); + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("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.getLastAttemptDate().getTime()>executionTaskA.getCreateDate().getTime()).isTrue(); - changeCreationDate(executionTaskA); - SoTaskProcessor.processOrderItem(executionTaskA); - serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); + @Test + public void testE2EExecutionTaskFailed() throws Exception { - } + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess( + serviceOrderRepository, executionTaskRepository, ActionType.ADD); - assertThat(executionTaskRepository.count()).isEqualTo(0); + Context.removeWireMockMapping( + "/onap/so/infra/e2eServiceInstances/v3/serviceId/operations/operationId"); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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.getLastAttemptDate().getTime() > executionTaskA.getCreateDate().getTime()) + .isTrue(); + changeCreationDate(executionTaskA); + SoTaskProcessor.processOrderItem(executionTaskA); + + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - @Test - public void testExecutionTaskFailedNoSoResponse() throws Exception { + } - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); + assertThat(executionTaskRepository.count()).isEqualTo(0); - Context.removeWireMockMapping("/onap/so/infra/serviceInstantiation/v7/serviceInstances/"); + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } + @Test + public void testExecutionTaskFailedNoSoResponse() throws Exception { - assertThat(executionTaskRepository.count()).isEqualTo(0); + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + Context.removeWireMockMapping("/onap/so/infra/serviceInstantiation/v7/serviceInstances/"); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); } - @Test - public void testExecutionTaskFailedNoSoAndStatusResponse() throws Exception { + assertThat(executionTaskRepository.count()).isEqualTo(0); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); - Context.removeWireMockMapping("/onap/so/infra/serviceInstantiation/v7/serviceInstances/"); - Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); + } - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } + @Test + public void testExecutionTaskFailedNoSoAndStatusResponse() throws Exception { - assertThat(executionTaskRepository.count()).isEqualTo(0); + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + + Context.removeWireMockMapping("/onap/so/infra/serviceInstantiation/v7/serviceInstances/"); + Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); } - @Test - public void testE2EExecutionTaskFailedNoSoAndStatusResponse() throws Exception { + assertThat(executionTaskRepository.count()).isEqualTo(0); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); + } - Context.removeWireMockMapping("/onap/so/infra/e2eServiceInstances/v3"); - Context.removeWireMockMapping("/onap/so/infra/e2eServiceInstances/v3/serviceId/operations/operationId"); + @Test + public void testE2EExecutionTaskFailedNoSoAndStatusResponse() throws Exception { + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForE2EExecutionTaskSucess( + serviceOrderRepository, executionTaskRepository, ActionType.ADD); - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } + Context.removeWireMockMapping("/onap/so/infra/e2eServiceInstances/v3"); + Context.removeWireMockMapping( + "/onap/so/infra/e2eServiceInstances/v3/serviceId/operations/operationId"); - assertThat(executionTaskRepository.count()).isEqualTo(0); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("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 testExecutionTaskFailedBadRequestSo() throws Exception { + } - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + + @Test + public void testExecutionTaskFailedBadRequestSo() throws Exception { + + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, executionTaskRepository, ActionType.ADD); - changeWireMockResponse("/onap/so/infra/serviceInstantiation/v7/serviceInstances/",400,"\"serviceException\": {\n" - + " \"messageId\": \"SVC0002\",\n" + changeWireMockResponse("/onap/so/infra/serviceInstantiation/v7/serviceInstances/", 400, + "\"serviceException\": {\n" + " \"messageId\": \"SVC0002\",\n" + " \"text\": \"Error parsing request. org.openecomp.mso.apihandler.common.ValidationException: serviceInstance already existsd\"\n" + " }"); - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } - - assertThat(executionTaskRepository.count()).isEqualTo(0); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); + } - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - if(serviceOrderItem.getId().equals("A")) { - assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1); - assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("105"); - assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()).isEqualTo("service.name"); - } - } + assertThat(executionTaskRepository.count()).isEqualTo(0); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + if (serviceOrderItem.getId().equals("A")) { + assertThat(serviceOrderItem.getOrderItemMessage().size()).isEqualTo(1); + assertThat(serviceOrderItem.getOrderItemMessage().get(0).getCode()).isEqualTo("105"); + assertThat(serviceOrderItem.getOrderItemMessage().get(0).getField()) + .isEqualTo("service.name"); + } } + } - @Test - public void testExecutionTaskModifySuccess() throws Exception { - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + @Test + public void testExecutionTaskModifySuccess() throws Exception { + + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, executionTaskRepository, ActionType.MODIFY); - ExecutionTask executionTaskB; - - - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - if (serviceOrderItem.getId().equals("A")) { - //assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS); - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS_MODIFY_ITEM_TO_CREATE); - } else { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED); - } - } - SoTaskProcessor.processOrderItem(executionTaskA); - serviceOrderChecked = getServiceOrder("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); - SoTaskProcessor.processOrderItem(executionTaskB); - - serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.COMPLETED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.COMPLETED); - - } - - assertThat(executionTaskRepository.count()).isEqualTo(0); + ExecutionTask executionTaskB; + + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + if (serviceOrderItem.getId().equals("A")) { + // assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS); + assertThat(serviceOrderItem.getState()) + .isEqualTo(StateType.INPROGRESS_MODIFY_ITEM_TO_CREATE); + } else { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED); + } + } + SoTaskProcessor.processOrderItem(executionTaskA); + serviceOrderChecked = getServiceOrder("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); + SoTaskProcessor.processOrderItem(executionTaskB); + + serviceOrderChecked = getServiceOrder("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 testExecutionTaskModifyFailed() throws Exception { - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + @Test + public void testExecutionTaskModifyFailed() throws Exception { + + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, executionTaskRepository, ActionType.MODIFY); - ExecutionTask executionTaskB; - Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); - - - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - if (serviceOrderItem.getId().equals("A")) { - //assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS); - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS_MODIFY_REQUEST_DELETE_SEND); - } else { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED); - } - } - executionTaskA = getExecutionTask("A"); - assertThat(executionTaskA.getLastAttemptDate().getTime()>executionTaskA.getCreateDate().getTime()).isTrue(); - changeCreationDate(executionTaskA); - SoTaskProcessor.processOrderItem(executionTaskA); - - serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - - } - - assertThat(executionTaskRepository.count()).isEqualTo(0); + ExecutionTask executionTaskB; + Context.removeWireMockMapping("/onap/so/infra/orchestrationRequests/v7/requestId"); + + + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.INPROGRESS); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + if (serviceOrderItem.getId().equals("A")) { + // assertThat(serviceOrderItem.getState()).isEqualTo(StateType.INPROGRESS); + assertThat(serviceOrderItem.getState()) + .isEqualTo(StateType.INPROGRESS_MODIFY_REQUEST_DELETE_SEND); + } else { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.ACKNOWLEDGED); + } + } + executionTaskA = getExecutionTask("A"); + assertThat( + executionTaskA.getLastAttemptDate().getTime() > executionTaskA.getCreateDate().getTime()) + .isTrue(); + changeCreationDate(executionTaskA); + SoTaskProcessor.processOrderItem(executionTaskA); + + serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); } - @Test - public void testExecutionTaskWithoutOnap() throws Exception { - Context.stopWiremock(); - ExecutionTask executionTaskA = ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, - executionTaskRepository, ActionType.ADD); + assertThat(executionTaskRepository.count()).isEqualTo(0); - SoTaskProcessor.processOrderItem(executionTaskA); - ServiceOrder serviceOrderChecked = getServiceOrder("test"); - assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); - for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { - assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); - } - assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0); - assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("502"); - assertThat(serviceOrderChecked.getOrderMessage().get(0).getMessageInformation()).isEqualTo("Problem with SO API"); + } - assertThat(executionTaskRepository.count()).isEqualTo(0); - Context.startWiremock(); + @Test + public void testExecutionTaskWithoutOnap() throws Exception { + Context.stopWiremock(); + ExecutionTask executionTaskA = + ServiceOrderExecutionTaskAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository, + executionTaskRepository, ActionType.ADD); + SoTaskProcessor.processOrderItem(executionTaskA); + ServiceOrder serviceOrderChecked = getServiceOrder("test"); + assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.FAILED); + for (ServiceOrderItem serviceOrderItem : serviceOrderChecked.getOrderItem()) { + assertThat(serviceOrderItem.getState()).isEqualTo(StateType.FAILED); } + assertThat(serviceOrderChecked.getOrderMessage().size()).isGreaterThan(0); + assertThat(serviceOrderChecked.getOrderMessage().get(0).getCode()).isEqualTo("502"); + assertThat(serviceOrderChecked.getOrderMessage().get(0).getMessageInformation()) + .isEqualTo("Problem with SO API"); + + assertThat(executionTaskRepository.count()).isEqualTo(0); + Context.startWiremock(); + + } -}
\ No newline at end of file +} diff --git a/src/test/resources/karatetest/features/00--ServiceCatalog.feature b/src/test/resources/karatetest/features/00--ServiceCatalog.feature index 728d3c8..25f15df 100644 --- a/src/test/resources/karatetest/features/00--ServiceCatalog.feature +++ b/src/test/resources/karatetest/features/00--ServiceCatalog.feature @@ -42,12 +42,12 @@ And match $.serviceSpecCharacteristic contains { name : 'vFW_ServiceCharacteristics', description : 'This object describes all the inputs needed from the client to interact with the vFW Service Topology', - valueType : 'Object', + valueType : 'object', @type : 'ONAPServiceCharacteristic', @schemaLocation : 'null', serviceSpecCharacteristicValue : { - valueType : 'Object', + valueType : 'object', @schemaLocation : '/serviceSpecification/462f84e5-f0e5-44c5-ab95-38fb4bf77064/specificationInputSchema', @type : 'vFW_ServiceCharacteristic', } |