summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-02-08 15:21:47 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-08 15:21:47 +0000
commitb3bc8b2a2cde4a72fae4d8f702b9fc87f6f138f1 (patch)
treed96281c1290c4ecbe9b3d59f10dc404428b38d46 /bpmn/so-bpmn-tasks/src/test
parent3f0d58fab3b6c7d4c1b5441de0670d4e656360cd (diff)
parentf73e27f96ee88bee8f95da6470d5b7693efd2100 (diff)
Merge "provide correct custIds"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json65
3 files changed, 150 insertions, 5 deletions
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 7b348c8cb3..24b87277c4 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
@@ -37,9 +37,11 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
+import java.util.Set;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -70,6 +72,8 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
+import org.onap.so.db.catalog.beans.ConfigurationResource;
+import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.InstanceGroup;
@@ -77,6 +81,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.serviceinstancebeans.RequestDetails;
@@ -854,6 +859,63 @@ public class WorkflowActionTest extends BaseTaskTest {
,"DeleteNetworkCollectionBB");
}
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception{
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception{
+ String gAction = "createInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ List<CvnfcCustomization> cvnfcCustomizations = new ArrayList<CvnfcCustomization>();
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setToscaNodeType("FabricConfiguration");
+ vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+ Set<VnfVfmoduleCvnfcConfigurationCustomization> custSet = new HashSet<VnfVfmoduleCvnfcConfigurationCustomization>();
+ custSet.add(vnfVfmoduleCvnfcConfigurationCustomization);
+ cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(custSet);
+ cvnfcCustomizations.add(cvnfcCustomization);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID("fc25201d-36d6-43a3-8d39-fdae88e526ae", "9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(cvnfcCustomizations);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
+ }
+
/**
* WorkflowActionBB Tests
*/
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
index 297d75a104..2dd4033aa2 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java
@@ -57,6 +57,10 @@ import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@RunWith(MockitoJUnitRunner.class)
public class WorkflowActionUnitTest {
@@ -87,9 +91,16 @@ public class WorkflowActionUnitTest {
"flow y",
"ActivateFabricConfigurationBB",
"flow z");
- doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(ArgumentMatchers.isNull(), ArgumentMatchers.isNull());
+ doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(ArgumentMatchers.any(String.class), ArgumentMatchers.isNull());
- List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
+ ServiceInstancesRequest sIRequest = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ requestDetails.setModelInfo(modelInfo);
+ RelatedInstance relatedInstance = new RelatedInstance();
+ sIRequest.setRequestDetails(requestDetails);
+
+ List<OrchestrationFlow> result = workflowAction.filterOrchFlows(sIRequest, flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
assertThat(result, is(flows));
}
@@ -103,7 +114,14 @@ public class WorkflowActionUnitTest {
"ActivateFabricConfigurationBB",
"flow z");
- List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
+ ServiceInstancesRequest sIRequest = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("");
+ requestDetails.setModelInfo(modelInfo);
+ sIRequest.setRequestDetails(requestDetails);
+
+ List<OrchestrationFlow> result = workflowAction.filterOrchFlows(sIRequest, flows, WorkflowType.VFMODULE, mock(DelegateExecution.class));
List<OrchestrationFlow> expected = createFlowList(
"flow x",
"flow y",
@@ -147,7 +165,7 @@ public class WorkflowActionUnitTest {
doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any(), any());
workflowAction.selectExecutionList(execution);
- verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any());
+ verify(workflowAction, times(1)).filterOrchFlows(any(), eq(flows), any(), any());
flow = new OrchestrationFlow();
flow.setFlowName("flow y");
@@ -155,7 +173,7 @@ public class WorkflowActionUnitTest {
when(execution.getVariable(eq("aLaCarte"))).thenReturn(false);
workflowAction.selectExecutionList(execution);
- verify(workflowAction, never()).filterOrchFlows(eq(flows), any(), any());
+ verify(workflowAction, never()).filterOrchFlows(any(), eq(flows), any(), any());
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json
new file mode 100644
index 0000000000..332ad4500c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleCreateWithFabric.json
@@ -0,0 +1,65 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelCustomizationName": "model-cust-name",
+ "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367",
+ "modelType": "vfModule",
+ "modelName": "test-model-name",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b",
+ "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60",
+ "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b",
+ "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60",
+ "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367",
+ "modelInstanceName": "test-model-instance-name"
+ },
+ "requestInfo": {
+ "source": "VID",
+ "instanceName": "instanceName",
+ "suppressRollback": false,
+ "requestorId": "user"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de",
+ "modelInfo": {
+ "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f",
+ "modelType": "service",
+ "modelName": "model-name",
+ "modelVersion": "1.0",
+ "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f",
+ "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f",
+ "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d",
+ "modelInfo": {
+ "modelCustomizationName": "modle-cust-name",
+ "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811",
+ "modelType": "vnf",
+ "modelName": "modle-name",
+ "modelVersion": "1.0",
+ "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7",
+ "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae",
+ "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7",
+ "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811",
+ "modelInstanceName": "model-inst-name"
+ }
+ }
+ }
+ ],
+ "cloudConfiguration": {
+ "tenantId": "872f331350c54e59991a8de2cbffb40c",
+ "cloudOwner": "my-custom-cloud-owner",
+ "lcpCloudRegionId": "cloud-region"
+ },
+ "requestParameters": {
+ "usePreload": true
+ }
+ }
+} \ No newline at end of file