summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authormamed.mamedov <mamed.mamedov@telekom.com>2022-05-30 17:37:24 +0300
committermamed.mamedov <mamed.mamedov@telekom.com>2022-05-30 17:37:24 +0300
commit7afa4fdaecb5df4e6e67f94a46825ebbe6050110 (patch)
tree9009e632333299b13641b4806aa40b97ccfb9086 /bpmn/so-bpmn-tasks/src/test
parentf2f6144f8600f87b8dce092574c0541eb17389b8 (diff)
Enable DeleteChildService functionality
Issue-ID: SO-3830 Change-Id: I5cf8b1a998839813fd59576eb70eb79c72f2c2fe Signed-off-by: mamed.mamedov <mamed.mamedov@telekom.com>
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.java23
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java56
2 files changed, 76 insertions, 3 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
index d1db3aadcd..e57232ebb7 100644
--- 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
@@ -53,6 +53,7 @@ public class ChildServiceRequestBuilderTest {
context.setProductFamilyId("FamilyId");
context.setSource("source");
context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setCloudOwner("CloudOwner");
@@ -82,10 +83,26 @@ public class ChildServiceRequestBuilderTest {
gbb.setServiceInstance(serviceInstance);
mockExecution = mock(BuildingBlockExecution.class);
doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
}
@Test
- public void childServiceRequestBuilderTest() {
+ 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())
@@ -180,6 +197,7 @@ public class ChildServiceRequestBuilderTest {
context.setProductFamilyId("FamilyId");
context.setSource("source");
context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setCloudOwner("CloudOwner");
@@ -198,6 +216,7 @@ public class ChildServiceRequestBuilderTest {
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")
@@ -231,6 +250,4 @@ public class ChildServiceRequestBuilderTest {
}
return null;
}
-
-
}
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 2725626c1a..9377daea5e 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;
@@ -364,4 +368,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());
+ }
}