aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java81
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java183
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json40
5 files changed, 159 insertions, 154 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 1a49e3af7f..6f11882281 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -37,6 +37,7 @@ import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.SerializationUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
import org.onap.aai.domain.yang.GenericVnf;
@@ -460,9 +461,8 @@ public class WorkflowAction {
return vnfcs;
}
- protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
-
- List<T> configurations = new ArrayList<>();
+ protected <T> T getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) throws Exception {
+ T configuration = null;
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
@@ -472,12 +472,19 @@ public class WorkflowAction {
Relationships relationships = relationshipsOp.get();
List<AAIResultWrapper> configurationResultWrappers =
this.getResultWrappersFromRelationships(relationships, type);
- for (AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
- Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
- configurationOp.ifPresent(configurations::add);
+ if (configurationResultWrappers.size() > 1) {
+ String multipleRelationshipsError =
+ "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations";
+ throw new Exception(multipleRelationshipsError);
+ }
+ if (!configurationResultWrappers.isEmpty()) {
+ Optional<T> configurationOp = configurationResultWrappers.get(0).asBean(resultClass);
+ if (configurationOp.isPresent()) {
+ configuration = configurationOp.get();
+ }
}
}
- return configurations;
+ return configuration;
}
protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships,
@@ -519,33 +526,26 @@ public class WorkflowAction {
List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId,
org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
for (org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
- List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc,
+ WorkflowResourceIds workflowIdsCopy = SerializationUtils.clone(dataObj.getWorkflowResourceIds());
+ org.onap.aai.domain.yang.Configuration configuration = getRelatedResourcesInVnfc(vnfc,
org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- if (configurations.size() > 1) {
- String multipleRelationshipsError =
- "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations";
- buildAndThrowException(dataObj.getExecution(), "Exception in getConfigBuildingBlock: ",
- new Exception(multipleRelationshipsError));
- }
- for (org.onap.aai.domain.yang.Configuration configuration : configurations) {
- dataObj.getWorkflowResourceIds().setConfigurationId(configuration.getConfigurationId());
- for (OrchestrationFlow orchFlow : result) {
- dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
- dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
- dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
- String vnfcName = getVnfcNameForConfiguration(configuration);
- if (vnfcName == null || vnfcName.isEmpty()) {
- buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
- + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
- new Exception("Vnfc and Configuration do not match"));
- }
- ExecuteBuildingBlock ebb =
- buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), dataObj.getResourceKey(),
- dataObj.getApiVersion(), dataObj.getResourceId(), dataObj.getRequestAction(),
- dataObj.isaLaCarte(), dataObj.getVnfType(), dataObj.getWorkflowResourceIds(),
- dataObj.getRequestDetails(), false, null, vnfcName, true, null);
- flowsToExecuteConfigs.add(ebb);
+ workflowIdsCopy.setConfigurationId(configuration.getConfigurationId());
+ for (OrchestrationFlow orchFlow : result) {
+ dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+ dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID);
+ String vnfcName = vnfc.getVnfcName();
+ if (vnfcName == null || vnfcName.isEmpty()) {
+ buildAndThrowException(dataObj.getExecution(), "Exception in create execution list "
+ + ": VnfcName does not exist or is null while there is a configuration for the vfModule",
+ new Exception("Vnfc and Configuration do not match"));
}
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(),
+ dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(),
+ dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), workflowIdsCopy,
+ dataObj.getRequestDetails(), false, null, vnfcName, true, null);
+ flowsToExecuteConfigs.add(ebb);
+
}
}
return flowsToExecuteConfigs;
@@ -613,23 +613,6 @@ public class WorkflowAction {
return orchFlows;
}
- protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) {
- AAIResultWrapper wrapper = new AAIResultWrapper(configuration);
- Optional<Relationships> relationshipsOp = wrapper.getRelationships();
- if (!relationshipsOp.isPresent()) {
- logger.debug("No relationships were found for Configuration in AAI");
- return null;
- }
- Relationships relationships = relationshipsOp.get();
- List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
- if (vnfcResultWrappers.size() != 1) {
- logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
- }
- Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
- return vnfcOp.map(Vnfc::getVnfcName).orElse(null);
-
- }
-
protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
int count = 0;
for (Resource resource : vfModuleResources) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index 155011ece0..7420df144a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -459,11 +459,10 @@ public class WorkflowActionBBTasks {
}
}
- protected String getConfigurationId(Vnfc vnfc) {
- List<Configuration> configurations =
+ protected String getConfigurationId(Vnfc vnfc) throws Exception {
+ Configuration configuration =
workflowAction.getRelatedResourcesInVnfc(vnfc, Configuration.class, AAIObjectType.CONFIGURATION);
- if (!configurations.isEmpty()) {
- Configuration configuration = configurations.get(0);
+ if (configuration != null) {
return configuration.getConfigurationId();
} else {
return UUID.randomUUID().toString();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index 70b10c5195..a7ee89f073 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -678,7 +678,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void getConfigurationId() {
+ public void getConfigurationId() throws Exception {
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("modelInvariantId");
vnfc.setVnfcName("testVnfcName");
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 8f104566a4..e975f44426 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
@@ -43,6 +43,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -235,77 +236,6 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
- public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception {
- DelegateExecution delegateExecution = new DelegateExecutionFake();
- String gAction = "deleteInstance";
- String resource = "VfModule";
- delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- delegateExecution.setVariable("requestAction", gAction);
- String bpmnRequest =
- new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- delegateExecution.setVariable("bpmnRequest", bpmnRequest);
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("apiVersion", "7");
- delegateExecution.setVariable("requestUri",
- "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
- "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
- true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- doAnswer(invocation -> {
- DelegateExecutionFake execution = invocation.getArgument(0);
- execution.setVariable("WorkflowException", "exception");
- execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage");
- throw new BpmnError("WorkflowException");
- }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000,
- "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations");
-
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
-
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setModelCustomizationId("modelCustimizationId");
- configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration();
- configuration1.setConfigurationId("configurationId");
- configuration1.setModelCustomizationId("modelCustimizationId");
- configuration1.setConfigurationName("testConfigurationName");
- configurations.add(configuration1);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
-
- thrown.expect(BpmnError.class);
- SPY_workflowAction.selectExecutionList(delegateExecution);
- assertEquals(
- "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations",
- delegateExecution.getVariable("WorkflowException"));
- }
-
- @Test
public void selectExecutionListDuplicateNameExceptionTest() throws Exception {
String gAction = "createInstance";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
@@ -1409,16 +1339,11 @@ public class WorkflowActionTest extends BaseTaskTest {
vnfcs.add(vnfc);
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
-
- doReturn("testVnfcName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
+ doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceVfModuleWithFabricOrchFlows);
@@ -1669,18 +1594,13 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
anyObject());
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
@@ -1738,6 +1658,81 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
+ public void getConfigBuildingBlocksTest() throws Exception {
+ String gAction = "deleteInstance";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+ WorkflowType resourceType = WorkflowType.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("vnfId", "1234");
+ execution.setVariable("vfModuleId", "vfModuleId1234");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ RequestDetails requestDetails = sIRequest.getRequestDetails();
+ String requestAction = "deleteInstance";
+ String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
+ boolean aLaCarte = true;
+ String apiVersion = "7";
+ String vnfType = "vnfType";
+ String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
+ String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
+
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
+
+ ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest)
+ .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion)
+ .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+
+ org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration();
+ config1.setConfigurationId("config1");
+ org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration();
+ config2.setConfigurationId("config2");
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc();
+ vnfc1.setVnfcName("zauk53avetd02svm001");
+ org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc();
+ vnfc2.setVnfcName("zauk53avetd02tvm001");
+ vnfcs.add(vnfc1);
+ vnfcs.add(vnfc2);
+
+ when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(),
+ eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC));
+ doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1),
+ eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION));
+ doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2),
+ eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION));
+
+ List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
+
+ assertFalse(results.isEmpty());
+ assertEquals(2, results.size());
+ assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId());
+ assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId());
+ assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
+ assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName());
+ }
+
+ @Test
public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "VfModule";
@@ -1753,7 +1748,7 @@ public class WorkflowActionTest extends BaseTaskTest {
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
- "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
@@ -1769,21 +1764,10 @@ public class WorkflowActionTest extends BaseTaskTest {
when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
- anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
anyObject());
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
@@ -1853,10 +1837,9 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),
anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(
- vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- assertEquals(1, configurationsList.size());
- assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId());
+ org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc,
+ org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals("testConfigurationId", configuration.getConfigurationId());
}
/**
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json
new file mode 100644
index 0000000000..ac047a9638
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json
@@ -0,0 +1,40 @@
+{
+ "automated-assignment": false,
+ "heat-stack-id": "zauk53avetd02_base/5c7a8a55-edb8-458e-a7dc-2dbbc696682e",
+ "is-base-vf-module": true,
+ "model-customization-id": "521d5f9b-0b76-49d3-879e-fce8767f34eb",
+ "model-invariant-id": "f0ac6f78-543f-41ac-81c3-672a4d47001c",
+ "model-version-id": "215ea5bd-f0e0-4560-9f64-9a9716ff6178",
+ "module-index": 0,
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02svm001",
+ "related-to": "vnfc",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "zauk53avetd02svm001"
+ }
+ ],
+ "relationship-label": "org.onap.relationships.inventory.Uses"
+ },
+ {
+ "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02tvm001",
+ "related-to": "vnfc",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "zauk53avetd02tvm001"
+ }
+ ],
+ "relationship-label": "org.onap.relationships.inventory.Uses"
+ }
+ ]
+ },
+ "resource-version": "1595304004908",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/16b9c65d-70c7-47f0-aa03-7cdb8dfb76be/service-data/vnfs/vnf/9cf22c37-4f39-4fa5-a942-b72efc8f6450/vnf-data/vf-modules/vf-module/2cf0ecd4-737c-4a46-9097-adc2f0088483/vf-module-data/vf-module-topology/",
+ "vf-module-id": "2cf0ecd4-737c-4a46-9097-adc2f0088483",
+ "vf-module-name": "zauk53avetd02_base"
+} \ No newline at end of file