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/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java181
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java59
6 files changed, 213 insertions, 126 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
index 6831a656a8..92ed61df67 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/SdncInputParametersProvider.java
@@ -50,11 +50,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class SdncInputParametersProvider extends AbstractInputParametersProvider<GenericVnf> {
private static final Logger LOGGER = LoggerFactory.getLogger(SdncInputParametersProvider.class);
-
private static final String VNF_PARAMETERS_PATH = "$..vnf-parameters";
-
private final SDNCClient sdncClient;
-
private final ObjectMapper mapper;
@Autowired
@@ -68,34 +65,12 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
final String vnfName = genericVnf.getVnfName();
final String vnfType = getVnfType(genericVnf);
final String url = getPreloadVnfsUrl(vnfName, vnfType);
+ final InputParameter inputParameter = parseInputParametersUsingUrl(url);
- try {
- LOGGER.debug("Will query sdnc for input parameters using url: {}", url);
- final String jsonResponse = sdncClient.get(url);
- final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null);
-
- try {
-
- if (json != null) {
- final List<VnfParameter> vnfParametersArray =
- mapper.readValue(json, new TypeReference<List<VnfParameter>>() {});
- final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray);
- final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
- final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
- final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
- LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
- return inputParameter;
- }
-
- } catch (final IOException exception) {
- LOGGER.error("Unable to parse vnf parameters : {}", json, exception);
- }
- } catch (final Exception exception) {
- LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception);
- }
+ if (inputParameter != null)
+ return inputParameter;
LOGGER.warn("No input parameters found ...");
return NullInputParameter.NULL_INSTANCE;
-
}
private List<ExternalVirtualLink> getExtVirtualLinks(final Map<String, String> vnfParametersMap) {
@@ -109,19 +84,18 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
private Map<String, String> getAdditionalParameters(final Map<String, String> vnfParametersMap) {
final String additionalParamsString = vnfParametersMap.get(ADDITIONAL_PARAMS);
+
if (additionalParamsString != null && !additionalParamsString.isEmpty()) {
return parseAdditionalParameters(additionalParamsString);
}
return Collections.emptyMap();
}
-
private Map<String, String> getVnfParameterMap(final List<VnfParameter> array) {
if (array != null) {
return array.stream().filter(vnfParam -> vnfParam.getName() != null && vnfParam.getValue() != null)
.collect(Collectors.toMap(VnfParameter::getName, VnfParameter::getValue));
}
-
return Collections.emptyMap();
}
@@ -131,10 +105,43 @@ public class SdncInputParametersProvider extends AbstractInputParametersProvider
private String getVnfType(final GenericVnf genericVnf) {
final ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf();
- if (modelInfoGenericVnf != null && modelInfoGenericVnf.getModelName() != null) {
+ if (modelInfoGenericVnf != null) {
return modelInfoGenericVnf.getModelName();
}
return genericVnf.getVnfType();
}
+ private InputParameter parseInputParametersUsingUrl(String url) {
+ try {
+ LOGGER.debug("Will query sdnc for input parameters using url: {}", url);
+ final String jsonResponse = sdncClient.get(url);
+ final String json = JsonPathUtil.getInstance().locateResult(jsonResponse, VNF_PARAMETERS_PATH).orElse(null);
+ final InputParameter inputParameter = parseVnfParameters(json);
+
+ if (inputParameter != null)
+ return inputParameter;
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to retrieve/parse input parameters using URL: {} ", url, exception);
+ }
+ return null;
+ }
+
+ private InputParameter parseVnfParameters(String json) {
+ try {
+ if (json != null) {
+ final List<VnfParameter> vnfParametersArray =
+ mapper.readValue(json, new TypeReference<List<VnfParameter>>() {});
+ final Map<String, String> vnfParametersMap = getVnfParameterMap(vnfParametersArray);
+ final Map<String, String> additionalParameters = getAdditionalParameters(vnfParametersMap);
+ final List<ExternalVirtualLink> extVirtualLinks = getExtVirtualLinks(vnfParametersMap);
+ final InputParameter inputParameter = new InputParameter(additionalParameters, extVirtualLinks);
+ LOGGER.info("InputParameter found in sdnc response : {}", inputParameter);
+ return inputParameter;
+ }
+
+ } catch (final IOException exception) {
+ LOGGER.error("Unable to parse vnf parameters : {}", json, exception);
+ }
+ return null;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java
index ac939d04ec..bdd738b031 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/UserParamInputParametersProvider.java
@@ -40,12 +40,12 @@ public class UserParamInputParametersProvider extends AbstractInputParametersPro
final InputParameter inputParameter = new InputParameter();
final Object additionalParams = userParams.get(ADDITIONAL_PARAMS);
- if (additionalParams != null && additionalParams instanceof String) {
+ if (additionalParams instanceof String) {
inputParameter.setAdditionalParams(parseAdditionalParameters(additionalParams.toString()));
}
final Object extVirtualLinks = userParams.get(EXT_VIRTUAL_LINKS);
- if (extVirtualLinks != null && extVirtualLinks instanceof String) {
+ if (extVirtualLinks instanceof String) {
inputParameter.setExtVirtualLinks(parseExternalVirtualLinks(extVirtualLinks.toString()));
}
LOGGER.info("InputParameter found in userParams : {}", inputParameter);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
index 0d45dad6fe..2491c99bc4 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/utils/VnfParameter.java
@@ -35,30 +35,18 @@ public class VnfParameter {
@JsonProperty("vnf-parameter-value")
private String value;
- /**
- * @return the name
- */
public String getName() {
return name;
}
- /**
- * @param name the name to set
- */
public void setName(final String name) {
this.name = name;
}
- /**
- * @return the value
- */
public String getValue() {
return value;
}
- /**
- * @param value the value to set
- */
public void setValue(final String value) {
this.value = value;
}
@@ -66,10 +54,9 @@ public class VnfParameter {
@Override
public int hashCode() {
final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return Objects.hash(name, value);
+ int nameResult = prime + ((name == null) ? 0 : name.hashCode());
+ int valueResult = prime + ((value == null) ? 0 : value.hashCode());
+ return Objects.hash(nameResult, valueResult);
}
@Override
@@ -78,7 +65,6 @@ public class VnfParameter {
VnfParameter other = (VnfParameter) obj;
return Objects.equals(name, other.name) && Objects.equals(value, other.value);
}
-
return false;
}
@@ -86,5 +72,4 @@ public class VnfParameter {
public String toString() {
return "VnfParameter [name=" + name + ", value=" + value + "]";
}
-
}
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 985114abcd..9781f78789 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
@@ -146,6 +146,7 @@ public class WorkflowAction {
private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)";
private static final String CONTROLLER = "Controller";
private static final String DEFAULT_CLOUD_OWNER = "org.onap.so.cloud-owner";
+ private static final String HOMING = "homing";
@Autowired
protected BBInputSetup bbInputSetup;
@@ -198,16 +199,12 @@ public class WorkflowAction {
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
- flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
- if (flowsToExecute == null) {
- buildAndThrowException(execution, "Could not resume Macro flow. Error loading execution path.");
- }
+ String errorMessage = "Could not resume Macro flow. Error loading execution path.";
+ flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
} else if (isALaCarte && isResume) {
- flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
- if (flowsToExecute == null) {
- buildAndThrowException(execution,
- "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found");
- }
+ String errorMessage =
+ "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found";
+ flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
} else {
String vnfType = (String) execution.getVariable(VNF_TYPE);
String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration());
@@ -228,44 +225,19 @@ public class WorkflowAction {
|| requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS))
&& resourceType.equals(WorkflowType.VFMODULE)) {
logger.debug("Build a BB list for replacing BB modules");
- orchFlows = getVfModuleReplaceBuildingBlocks(new ConfigBuildingBlocksDataObject()
- .setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId)
- .setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId)
- .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType)
- .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails)
- .setExecution(execution).setReplaceInformation(replaceInfo));
- for (OrchestrationFlow orchFlow : orchFlows) {
- if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- List<OrchestrationFlow> configOrchFlows = new ArrayList<>();
- configOrchFlows.add(orchFlow);
- List<ExecuteBuildingBlock> configBuildingBlocks =
- getConfigBuildingBlocks(new ConfigBuildingBlocksDataObject()
- .setsIRequest(sIRequest).setOrchFlows(configOrchFlows)
- .setRequestId(requestId).setResourceKey(resourceKey)
- .setApiVersion(apiVersion).setResourceId(resourceId)
- .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType)
- .setWorkflowResourceIds(workflowResourceIds)
- .setRequestDetails(requestDetails).setExecution(execution)
- .setReplaceInformation(replaceInfo));
- flowsToExecute.addAll(configBuildingBlocks);
- } else {
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey,
- apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds,
- requestDetails, false, null, null, false, replaceInfo);
- flowsToExecute.add(ebb);
- }
- }
+ ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution,
+ sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId,
+ vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
+ orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
+
+ createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds,
+ requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows,
+ apiVersion, resourceKey, replaceInfo);
} else {
if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) {
- List<ExecuteBuildingBlock> configBuildingBlocks =
- getConfigBuildingBlocks(new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest)
- .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey)
- .setApiVersion(apiVersion).setResourceId(resourceId)
- .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType)
- .setWorkflowResourceIds(workflowResourceIds)
- .setRequestDetails(requestDetails).setExecution(execution));
-
- flowsToExecute.addAll(configBuildingBlocks);
+ addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId,
+ workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute,
+ vnfType, apiVersion, resourceKey, replaceInfo, orchFlows);
}
orchFlows =
orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION))
@@ -287,10 +259,7 @@ public class WorkflowAction {
// SERVICE-MACRO-ASSIGN will always get user params with a
// service.
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams =
- sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- containsService =
- userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
+ containsService = isContainsService(sIRequest);
if (containsService) {
traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
}
@@ -306,10 +275,7 @@ public class WorkflowAction {
// queries the SI and finds a VNF, macro fails.
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams =
- sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- containsService =
- userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
+ containsService = isContainsService(sIRequest);
}
if (containsService) {
foundRelated = traverseUserParamsService(execution, resourceList, sIRequest, requestAction);
@@ -330,7 +296,7 @@ public class WorkflowAction {
} else if (resourceType == WorkflowType.SERVICE
&& "deactivateInstance".equalsIgnoreCase(requestAction)) {
resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
- } else if (resourceType == WorkflowType.VNF && ("replaceInstance".equalsIgnoreCase(requestAction)
+ } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
|| ("recreateInstance".equalsIgnoreCase(requestAction)))) {
traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
@@ -343,15 +309,15 @@ public class WorkflowAction {
(int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count())
.append(" ");
}
- logger.info("Found {}", foundObjects.toString());
+ logger.info("Found {}", foundObjects);
if (orchFlows == null || orchFlows.isEmpty()) {
orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte,
cloudOwner, serviceType);
}
boolean vnfReplace = false;
- if (resourceType.equals(WorkflowType.VNF) && ("replaceInstance".equalsIgnoreCase(requestAction)
- || "replaceInstanceRetainAssignments".equalsIgnoreCase(requestAction))) {
+ if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
+ || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
vnfReplace = true;
}
flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion,
@@ -364,7 +330,7 @@ public class WorkflowAction {
if (resourceType == WorkflowType.SERVICE
&& (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE))
&& resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
- execution.setVariable("homing", true);
+ execution.setVariable(HOMING, true);
execution.setVariable("calledHoming", false);
}
if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
@@ -380,11 +346,10 @@ public class WorkflowAction {
// enable it.
if (sIRequest.getRequestDetails().getRequestParameters() != null
&& sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams =
- sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
for (Map<String, Object> params : userParams) {
if (params.containsKey(HOMINGSOLUTION)) {
- execution.setVariable("homing", !"none".equals(params.get(HOMINGSOLUTION)));
+ execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION)));
}
}
}
@@ -404,12 +369,7 @@ public class WorkflowAction {
if (!isResume) {
bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute);
}
- execution.setVariable("flowNames", flowNames);
- execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
- execution.setVariable("retryCount", 0);
- execution.setVariable("isRollback", false);
- execution.setVariable("flowsToExecute", flowsToExecute);
- execution.setVariable("isRollbackComplete", false);
+ setExecutionVariables(execution, flowsToExecute, flowNames);
} catch (Exception ex) {
if (!(execution.hasVariable("WorkflowException")
@@ -421,6 +381,85 @@ public class WorkflowAction {
}
}
+ private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
+ List<String> flowNames) {
+ execution.setVariable("flowNames", flowNames);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
+ execution.setVariable("retryCount", 0);
+ execution.setVariable("isRollback", false);
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("isRollbackComplete", false);
+ }
+
+ private boolean isContainsService(ServiceInstancesRequest sIRequest) {
+ boolean containsService;
+ List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
+ containsService = userParams.stream().anyMatch(param -> param.containsKey(USERPARAMSERVICE));
+ return containsService;
+ }
+
+ private List<Map<String, Object>> getListOfUserParams(ServiceInstancesRequest sIRequest) {
+ return sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ }
+
+ private List<ExecuteBuildingBlock> loadExecuteBuildingBlocks(DelegateExecution execution, String requestId,
+ String errorMessage) {
+ List<ExecuteBuildingBlock> flowsToExecute;
+ flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
+ if (flowsToExecute == null) {
+ buildAndThrowException(execution, errorMessage);
+ }
+ return flowsToExecute;
+ }
+
+ private ConfigBuildingBlocksDataObject createConfigBuildingBlocksDataObject(DelegateExecution execution,
+ ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds,
+ RequestDetails requestDetails, String requestAction, String resourceId, String vnfType,
+ List<OrchestrationFlow> orchFlows, String apiVersion, Resource resourceKey,
+ ReplaceInstanceRelatedInformation replaceInfo) {
+
+ return new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows)
+ .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId)
+ .setRequestAction(requestAction).setaLaCarte(true).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution)
+ .setReplaceInformation(replaceInfo);
+ }
+
+ private void createBuildingBlocksForOrchFlows(DelegateExecution execution, ServiceInstancesRequest sIRequest,
+ String requestId, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
+ String requestAction, String resourceId, List<ExecuteBuildingBlock> flowsToExecute, String vnfType,
+ List<OrchestrationFlow> orchFlows, String apiVersion, Resource resourceKey,
+ ReplaceInstanceRelatedInformation replaceInfo) throws Exception {
+
+ for (OrchestrationFlow orchFlow : orchFlows) {
+ if (orchFlow.getFlowName().contains(CONFIGURATION)) {
+ List<OrchestrationFlow> configOrchFlows = new ArrayList<>();
+ configOrchFlows.add(orchFlow);
+ addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds,
+ requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey,
+ replaceInfo, configOrchFlows);
+ } else {
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion,
+ resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null,
+ null, false, replaceInfo);
+ flowsToExecute.add(ebb);
+ }
+ }
+ }
+
+ private void addConfigBuildingBlocksToFlowsToExecuteList(DelegateExecution execution,
+ ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds,
+ RequestDetails requestDetails, String requestAction, String resourceId,
+ List<ExecuteBuildingBlock> flowsToExecute, String vnfType, String apiVersion, Resource resourceKey,
+ ReplaceInstanceRelatedInformation replaceInfo, List<OrchestrationFlow> configOrchFlows) throws Exception {
+
+ ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId,
+ workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, configOrchFlows, apiVersion,
+ resourceKey, replaceInfo);
+ List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(cbbdo);
+ flowsToExecute.addAll(configBuildingBlocks);
+ }
+
private Resource getResourceKey(ServiceInstancesRequest sIRequest, WorkflowType resourceType) {
String resourceId = "";
ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo();
@@ -847,7 +886,7 @@ public class WorkflowAction {
CollectionNetworkResourceCustomization collectionNetworkResourceCust =
getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup);
for (int i = 0; i < minNetworks; i++) {
- if (collectionNetworkResourceCust != null && collectionInstCust != null) {
+ if (collectionNetworkResourceCust != null) {
Resource resource = new Resource(WorkflowType.VIRTUAL_LINK,
collectionNetworkResourceCust.getModelCustomizationUUID(), false);
resource.setVirtualLinkKey(Integer.toString(i));
@@ -1092,7 +1131,7 @@ public class WorkflowAction {
String vnfCustomizationUUID = "";
String vfModuleCustomizationUUID = "";
if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
- List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
+ List<Map<String, Object>> userParams = getListOfUserParams(sIRequest);
for (Map<String, Object> params : userParams) {
if (params.containsKey(USERPARAMSERVICE)) {
ObjectMapper obj = new ObjectMapper();
@@ -1120,14 +1159,12 @@ public class WorkflowAction {
&& vfModuleCustomization.getVolumeHeatEnv() != null) {
resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
vfModuleCustomization.getModelCustomizationUUID(), false));
- foundRelated = true;
foundVfModuleOrVG = true;
}
if (vfModuleCustomization.getVfModule() != null
&& vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
&& vfModuleCustomization.getHeatEnvironment() != null) {
- foundRelated = true;
foundVfModuleOrVG = true;
Resource resource = new Resource(WorkflowType.VFMODULE,
vfModuleCustomization.getModelCustomizationUUID(), false);
@@ -1744,7 +1781,7 @@ public class WorkflowAction {
private void fillExecution(DelegateExecution execution, boolean suppressRollback, String resourceId,
WorkflowType resourceType) {
execution.setVariable("sentSyncResponse", false);
- execution.setVariable("homing", false);
+ execution.setVariable(HOMING, false);
execution.setVariable("calledHoming", false);
execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true);
execution.setVariable("suppressRollback", suppressRollback);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java
index 6254aae029..bc32489944 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java
@@ -39,13 +39,12 @@ public class HomingListener implements FlowManipulator {
public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB,
BuildingBlockExecution execution) {
- boolean homing = (boolean) execution.getVariable("homing");
- boolean calledHoming = (boolean) execution.getVariable("calledHoming");
+ boolean homing = execution.getVariable("homing");
+ boolean calledHoming = execution.getVariable("calledHoming");
if (homing && !calledHoming) {
currentBB.setHoming(true);
execution.setVariable("calledHoming", true);
}
}
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java
new file mode 100644
index 0000000000..d2383185d0
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListenerTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+
+public class HomingListenerTest {
+
+ private static final String CALLED_HOMING = "calledHoming";
+
+ @Test
+ public void shouldRunForAssignVnfBB() {
+ assertThat(new HomingListener().shouldRunFor("AssignVnfBB", false, null)).isTrue();
+ }
+
+ @Test
+ public void shouldNotRunForDifferentThanAssignVnfBB() {
+ assertThat(new HomingListener().shouldRunFor("someDifferentBB", false, null)).isFalse();
+ }
+
+ @Test
+ public void runWithHoming() {
+ // given
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("homing", true);
+ execution.setVariable(CALLED_HOMING, false);
+ BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(execution);
+ ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ // when
+ new HomingListener().run(null, executeBuildingBlock, buildingBlockExecution);
+ // then
+ assertThat(executeBuildingBlock.isHoming()).isTrue();
+ assertThat((boolean) buildingBlockExecution.getVariable(CALLED_HOMING)).isTrue();
+ }
+}