summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2022-08-05 14:19:19 +0200
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2022-08-05 14:19:57 +0200
commitb0f785e99096f230281d17e0fa89c21aca00fbac (patch)
treeecaa9d853037faa87310ab8c6562a3454e687179 /bpmn/so-bpmn-tasks/src/test
parent0d39f06a571e48ee3c8a05aca0c244d2595468e8 (diff)
parent2ef42cd813c85015322da874de668b79e790c5eb (diff)
Merge branch 'recursive-orch'
Issue-ID: SO-3980 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: Ie0cd0f973800196d5cb1e038db4a49208a6c4a3b
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java253
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java145
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java131
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java121
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml4
6 files changed, 709 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java
new file mode 100644
index 0000000000..e57232ebb7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java
@@ -0,0 +1,253 @@
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class ChildServiceRequestBuilderTest {
+
+ private BuildingBlockExecution mockExecution;
+ private List<Map<String, Object>> userParamsExpected;
+
+ @Before
+ public void setUp() throws IOException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"LcmDemo\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}],\"services\":[{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName\"},{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName\"}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"demo\"},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ userParamsExpected = request.getRequestDetails().getRequestParameters().getUserParams();
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("GlobalCustomerId");
+ customer.setSubscriberName("SubscriberName");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ Project project = new Project();
+ project.setProjectName("projectName");
+ serviceInstance.setProject(project);
+
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setCustomer(customer);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
+ }
+
+ @Test
+ public void deleteChildServiceRequestBuilderTest() {
+ Service parent = new Service();
+ Service child = new Service();
+
+ ChildServiceRequestBuilder builder = ChildServiceRequestBuilder.getInstance(mockExecution, parent, child);
+ ServiceInstancesRequest sir = builder
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+ Assert.assertEquals("serviceInstanceId",
+ sir.getRequestDetails().getRelatedInstanceList()[0].getRelatedInstance().getInstanceId());
+ }
+
+ @Test
+ public void createChildServiceRequestBuilderTest() {
+
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder.getInstance(mockExecution, "service1-instanceName")
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+
+ // modelInfo
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", modelInfo.getModelInvariantId());
+ Assert.assertEquals(ModelType.service, modelInfo.getModelType());
+ Assert.assertEquals("GuilinLcmSVC", modelInfo.getModelName());
+ Assert.assertEquals("2.0", modelInfo.getModelVersion());
+ Assert.assertEquals("cs1-svc-modelCustomizationId", modelInfo.getModelCustomizationId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", modelInfo.getModelVersionId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", modelInfo.getModelUuid());
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", modelInfo.getModelInvariantUuid());
+
+ // requestInfo
+ RequestInfo requestInfo = sir.getRequestDetails().getRequestInfo();
+ Assert.assertNotNull(requestInfo.getCorrelator());
+ Assert.assertEquals("FamilyId", requestInfo.getProductFamilyId());
+ Assert.assertEquals("source", requestInfo.getSource());
+ Assert.assertEquals("service1-instanceName", requestInfo.getInstanceName());
+ Assert.assertEquals(false, requestInfo.getSuppressRollback());
+ Assert.assertEquals("RequestOrId", requestInfo.getRequestorId());
+
+ RelatedInstanceList[] relatedInstanceList = sir.getRequestDetails().getRelatedInstanceList();
+ Assert.assertEquals(1, relatedInstanceList.length);
+ RelatedInstance relatedInstance = relatedInstanceList[0].getRelatedInstance();
+ Assert.assertEquals("serviceInstanceId", relatedInstance.getInstanceId());
+ Assert.assertEquals(InstanceDirection.source, relatedInstance.getInstanceDirection());
+
+ ModelInfo parentModel = relatedInstance.getModelInfo();
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", parentModel.getModelInvariantId());
+ Assert.assertEquals(ModelType.service, parentModel.getModelType());
+ Assert.assertEquals("GuilinLcmSVC", parentModel.getModelName());
+ Assert.assertEquals("2.0", parentModel.getModelVersion());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", parentModel.getModelVersionId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", parentModel.getModelUuid());
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", parentModel.getModelInvariantUuid());
+
+ SubscriberInfo subsciberInfo = sir.getRequestDetails().getSubscriberInfo();
+ Assert.assertEquals("GlobalCustomerId", subsciberInfo.getGlobalSubscriberId());
+ Assert.assertEquals("SubscriberName", subsciberInfo.getSubscriberName());
+
+ CloudConfiguration cloudConfiguration = sir.getRequestDetails().getCloudConfiguration();
+ Assert.assertEquals("tenant-id", cloudConfiguration.getTenantId());
+ Assert.assertEquals("CloudOwner", cloudConfiguration.getCloudOwner());
+ Assert.assertEquals("my-region-id", cloudConfiguration.getLcpCloudRegionId());
+
+ org.onap.so.serviceinstancebeans.RequestParameters requestParameters =
+ sir.getRequestDetails().getRequestParameters();
+ Assert.assertEquals(2, requestParameters.getUserParams().size());
+ Assert.assertEquals(userParamsExpected.get(0), requestParameters.getUserParams().get(0));
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ try {
+ String expectedChildService =
+ mapper.writeValueAsString(getChildService(userParamsExpected, "service1-instanceName"));
+ String actualChildService =
+ mapper.writeValueAsString(requestParameters.getUserParams().get(1).get("service"));
+ Assert.assertEquals(expectedChildService, actualChildService);
+ } catch (Exception e) {
+ Assert.fail();
+ }
+
+ org.onap.so.serviceinstancebeans.Project project = sir.getRequestDetails().getProject();
+ Assert.assertEquals("projectName", project.getProjectName());
+
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = sir.getRequestDetails().getOwningEntity();
+ Assert.assertEquals("owningEntityId", owningEntity.getOwningEntityId());
+ Assert.assertEquals("owningEntityName", owningEntity.getOwningEntityName());
+ }
+
+ @Test
+ public void childServiceCloudConfigurationRequestBuilderTest() throws IOException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"onap-test-parent-child-service\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"215\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"iaas\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"services\":[{\"instanceParams\":[],\"resources\":{},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName-child\",\"cloudConfiguration\":{\"lcpCloudRegionId\":\"test\",\"tenantId\":\"1234567890\",\"cloudOwner\":\"demo\"}},{\"instanceParams\":[],\"resources\":{},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName-child\"}]},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"seb\"},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
+
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder
+ .getInstance(mockExecution, "service1-instanceName-child")
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+
+ CloudConfiguration cloudConfiguration = sir.getRequestDetails().getCloudConfiguration();
+ Assert.assertEquals("1234567890", cloudConfiguration.getTenantId());
+ Assert.assertEquals("demo", cloudConfiguration.getCloudOwner());
+ Assert.assertEquals("test", cloudConfiguration.getLcpCloudRegionId());
+ }
+
+ private Service getChildService(List<Map<String, Object>> userParams, String serviceInstanceName)
+ throws IOException {
+ String USERPARAMSERVICE = "service";
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
+ Service validate = obj.readValue(input, Service.class);
+ if (validate.getResources().getServices() != null) {
+ for (Service service : validate.getResources().getServices()) {
+ if (serviceInstanceName.equals(service.getInstanceName())) {
+ return service;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java
new file mode 100644
index 0000000000..6392d25998
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java
@@ -0,0 +1,145 @@
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.logging.filter.base.ONAPComponentsList;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.MockControllerBB;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.ApiHandlerClient;
+import org.onap.so.client.orchestration.ApiHandlerClientException;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_INSTANCE_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_PAYLOAD;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {CreateChildServiceBB.class, MockControllerBB.class, ExceptionBuilder.class})
+public class CreateChildServiceBBTest {
+
+ @Autowired
+ private CreateChildServiceBB createChildServiceBB;
+
+ @MockBean
+ private BuildingBlockExecution execution;
+
+ @MockBean
+ private ApiHandlerClient apiHandlerClient;
+
+ @MockBean
+ private ExceptionBuilder exceptionBuilder;
+
+ @Before
+ public void setUp() throws IOException, ApiHandlerClientException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"LcmDemo\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}],\"services\":[{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName\"},{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName\"}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"demo\"},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("GlobalCustomerId");
+ customer.setSubscriberName("SubscriberName");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ Project project = new Project();
+ project.setProjectName("projectName");
+ serviceInstance.setProject(project);
+
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setCustomer(customer);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+
+ Map<ResourceKey, String> map = new HashMap<>();
+ map.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, "service1-instanceName");
+
+ when(execution.getGeneralBuildingBlock()).thenReturn(gbb);
+ when(execution.getLookupMap()).thenReturn(map);
+
+ ServiceInstancesResponse response = new ServiceInstancesResponse();
+ response.setRequestReferences(new RequestReferences());
+ response.getRequestReferences().setInstanceId("instanceId");
+ response.getRequestReferences().setRequestId("requestId");
+
+ when(apiHandlerClient.createServiceInstance(any())).thenReturn(response);
+ }
+
+ @Test
+ public void buildRequestTest() {
+ createChildServiceBB.buildRequest(execution);
+ }
+
+ @Test
+ public void sendRequestTest() throws Exception {
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails details = new RequestDetails();
+ details.setRequestInfo(new RequestInfo());
+ details.getRequestInfo().setCorrelator("correlator");
+ sir.setRequestDetails(details);
+
+ when(execution.getVariable(CHILD_SVC_REQ_PAYLOAD)).thenReturn(sir);
+ createChildServiceBB.sendRequest(execution);
+ verify(execution).setVariable(CHILD_SVC_REQ_ID, "requestId");
+ verify(execution).setVariable(CHILD_SVC_INSTANCE_ID, "instanceId");
+ verify(execution).setVariable(CHILD_SVC_REQ_CORRELATION_ID, "correlator");
+ }
+
+ @Test
+ public void handleFailureTest() {
+ createChildServiceBB.handleFailure(execution);
+ verify(exceptionBuilder).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), anyInt(),
+ anyString(), any(ONAPComponentsList.class));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index 7f44c97f59..aeef976fb4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -26,9 +26,19 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
import java.sql.Timestamp;
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Rule;
@@ -271,4 +281,125 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class));
}
+
+ @Test
+ public void invokeSendMessageForChildServiceRollBackCompletedSuccessfully() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully."))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(true);
+ when(mockExecution.getVariable("isRollback")).thenReturn(true);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully.");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+ @Test
+ public void invokeSendMessageForChildServiceRollBackFailure() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "error in rollback"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(PARENT_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(false);
+ when(mockExecution.getVariable("isRollback")).thenReturn(true);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR,
+ "Failed to determine rollback error message.");
+
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "error in rollback");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+ @Test
+ public void invokeSendMessageForChildServiceNoRollBack() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "error in rollback"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(PARENT_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(false);
+ when(mockExecution.getVariable("isRollback")).thenReturn(false);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Failed to determine error message");
+
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "error in rollback");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
index 76763e8ca8..2d41a24ac3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
@@ -32,7 +32,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.ComposedResources;
+import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aaiclient.client.aai.entities.Relationships;
@@ -368,4 +372,56 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2));
return resourceList;
}
+
+ @Test
+ public void traverseServiceInstanceChildServiceTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ Resource parentResource = new Resource(WorkflowType.SERVICE, "parentId", false, null);
+ String resourceId = "siP";
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId(resourceId);
+
+ RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey("service-instance.service-instance-id");
+ relationshipData.setRelationshipValue("80ced9d5-666e-406b-88f0-a05d31328b70");
+ RelatedToProperty relatedToProperty = new RelatedToProperty();
+ relatedToProperty.setPropertyKey("service-instance.service-instance-name");
+ relatedToProperty.setPropertyValue("child_euler_002");
+
+ RelationshipData relationshipData1 = new RelationshipData();
+ relationshipData1.setRelationshipKey("service-instance.service-instance-id");
+ relationshipData1.setRelationshipValue("fa5640af-c827-4372-baae-7f1c50fdb5ed");
+ RelatedToProperty relatedToProperty1 = new RelatedToProperty();
+ relatedToProperty1.setPropertyKey("service-instance.service-instance-name");
+ relatedToProperty.setPropertyValue("child_euler_001");
+
+
+ Relationship relationship = new Relationship();
+ Relationship relationship1 = new Relationship();
+ relationship.setRelatedTo("service-instance");
+ relationship1.setRelatedTo("service-instance");
+ relationship.getRelationshipData().add(relationshipData);
+ relationship.getRelatedToProperty().add(relatedToProperty);
+ relationship1.getRelationshipData().add(relationshipData1);
+ relationship1.getRelatedToProperty().add(relatedToProperty1);
+
+ RelationshipList relationshipList = new RelationshipList();
+ RelationshipList relationshipList1 = new RelationshipList();
+ relationshipList.getRelationship().add(relationship);
+ relationshipList1.getRelationship().add(relationship1);
+
+ ComposedResource composedResource = new ComposedResource();
+ composedResource.setRelationshipList(relationshipList);
+ ComposedResource composedResource1 = new ComposedResource();
+ composedResource1.setRelationshipList(relationshipList);
+
+ ComposedResources composedResources = new ComposedResources();
+ composedResources.getComposedResource().add(composedResource);
+ composedResources.getComposedResource().add(composedResource1);
+
+ serviceInstanceAAI.setComposedResources(composedResources);
+
+ serviceEBBLoader.traverseServiceInstanceChildService(resourceList, parentResource, serviceInstanceAAI);
+ assertEquals(2, resourceList.size());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java
new file mode 100644
index 0000000000..f3a04e6f54
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java
@@ -0,0 +1,121 @@
+package org.onap.so.client.orchestration;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.RestTemplate;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.instanceOf;
+
+
+@TestPropertySource(properties = {"mso.adapters.apihandler.endpoint=http://localhost:",
+ "mso.adapters.apihandler.auth=Basic dGVzdDp0ZXN0Cg=="})
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ApiHandlerClientTest {
+
+ @InjectMocks
+ private ApiHandlerClient client;
+
+ @Mock
+ protected RestTemplate restTemplate;
+
+ private ServiceInstancesRequest buildRequest(String incomingRequest) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ ServiceInstancesRequest request = null;
+ try {
+ request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ System.out.println("Java Object: " + request);
+ } catch (Exception e) {
+ System.out.println("Caught Exception " + e.getMessage());
+ Assert.fail("Could not build ServiceInstancesRequest object");
+ }
+ return request;
+ }
+
+ @Test
+ public void createServiceInstanceTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ ResponseEntity<ServiceInstancesResponse> responseEntity =
+ new ResponseEntity<ServiceInstancesResponse>(new ServiceInstancesResponse(), HttpStatus.ACCEPTED);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenReturn(responseEntity);
+
+ try {
+ ServiceInstancesResponse response = client.createServiceInstance(request);
+ assertThat(response, instanceOf(ServiceInstancesResponse.class));
+ } catch (ApiHandlerClientException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void createServiceInstanceErrorTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
+ try {
+ client.createServiceInstance(request);
+ Assert.fail("ApiHandlerClientException exception was not thrown");
+ } catch (ApiHandlerClientException e) {
+ assertEquals("Failed sending service createInstance request to api-handler. Error: ", e.getMessage());
+ }
+ }
+
+ @Test
+ public void deleteServiceInstanceTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ ResponseEntity<ServiceInstancesResponse> responseEntity =
+ new ResponseEntity<ServiceInstancesResponse>(new ServiceInstancesResponse(), HttpStatus.ACCEPTED);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenReturn(responseEntity);
+
+ try {
+ ServiceInstancesResponse response = client.deleteServiceInstance(request);
+ assertThat(response, instanceOf(ServiceInstancesResponse.class));
+ } catch (ApiHandlerClientException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void deleteServiceInstanceErrorTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
+ try {
+ client.deleteServiceInstance(request);
+ Assert.fail("ApiHandlerClientException exception was not thrown");
+ } catch (ApiHandlerClientException e) {
+ assertEquals("Failed sending service deleteInstance request to api-handler. Error: ", e.getMessage());
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index b64fc3318b..d3f5696c16 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -84,7 +84,9 @@ mso:
workflow:
message:
endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50