summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2020-12-08 08:46:38 +0100
committerpwielebs <piotr.wielebski@nokia.com>2020-12-17 08:35:34 +0100
commitea0e5318878bed8f87c26a8ea2157fae39d43913 (patch)
treed023de97e1acb6345cec16b37caa348eb8e42701 /bpmn/so-bpmn-tasks/src/test
parentfcf14bc2eddad4f3ef7f138a5b5c98b1e965fde9 (diff)
SO WorkflowAction refactor
- extract traverseUserParamsService() method from WorkflowAction class to UserParamsServiceTraversal class - move methods used only in traverseUserParamsService() method to UserParamsServiceTraversal class - change method signature from traverseUserParamsService to getResourceListFromUserParams() - create WorkFlowActionCommon for duplicated code Issue-ID: SO-3422 Signed-off-by: pwielebs <piotr.wielebski@nokia.com> Change-Id: Ic6a567eb7b323939e47335aa7938b83498f7a8f8
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java49
2 files changed, 49 insertions, 4 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index e8ce828652..ab83acaec2 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -24,7 +24,6 @@ package org.onap.so.bpmn;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
@@ -33,8 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
-import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
-import org.onap.aaiclient.client.aai.entities.Relationships;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.appc.ApplicationControllerAction;
@@ -162,5 +159,4 @@ public abstract class BaseTaskTest extends TestDataSetup {
@Mock
protected NamingRequestObject namingRequestObject;
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 7f22c5138e..0a3f74c2ea 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -35,6 +35,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -127,6 +128,10 @@ public class WorkflowActionTest extends BaseTaskTest {
@Mock
protected Environment environment;
+
+ @Mock
+ protected UserParamsServiceTraversal userParamsServiceTraversal;
+
@InjectMocks
protected WorkflowAction workflowAction;
private DelegateExecution execution;
@@ -286,6 +291,8 @@ public class WorkflowActionTest extends BaseTaskTest {
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
+ .thenReturn(prepareListWithResources());
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
@@ -334,6 +341,8 @@ public class WorkflowActionTest extends BaseTaskTest {
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
+ .thenReturn(prepareListWithResources());
when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "att-aic")).thenReturn(northBoundRequest);
@@ -606,6 +615,8 @@ public class WorkflowActionTest extends BaseTaskTest {
VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
+ .thenReturn(prepareListWithResources());
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
@@ -622,6 +633,7 @@ public class WorkflowActionTest extends BaseTaskTest {
"ActivateVolumeGroupBB", "CreateVfModuleBB", "CreateVfModuleBB", "CreateVfModuleBB",
"ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
"ActivateServiceInstanceBB");
+
assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
int randomUUIDLength = UUID.randomUUID().toString().length();
assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
@@ -3100,6 +3112,32 @@ public class WorkflowActionTest extends BaseTaskTest {
}
}
+ @Test
+ public void foundRelatedTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+
+ assertEquals(workflowAction.foundRelated(resourceList), true);
+ }
+
+ @Test
+ public void containsWorkflowTypeTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.PNF, "resource id", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+
+ assertEquals(workflowAction.containsWorkflowType(resourceList, WorkflowType.PNF), true);
+ assertEquals(workflowAction.containsWorkflowType(resourceList, WorkflowType.VNF), true);
+ assertEquals(workflowAction.containsWorkflowType(resourceList, WorkflowType.NETWORK), true);
+ assertEquals(workflowAction.containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION), true);
+ assertEquals(workflowAction.containsWorkflowType(resourceList, WorkflowType.CONFIGURATION), false);
+ }
+
private List<Pair<WorkflowType, String>> getExpectedResourceIds() {
List<Pair<WorkflowType, String>> resourceIds = new ArrayList<>();
resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, "testVnfId1"));
@@ -3141,4 +3179,15 @@ public class WorkflowActionTest extends BaseTaskTest {
private String readBpmnRequestFromFile(String fileName) throws IOException {
return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName)));
}
+
+ private List<Resource> prepareListWithResources() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false));
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ return resourceList;
+ }
}