use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleNoFabricCreateTest.
@Test
public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception {
String gAction = "createInstance";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
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");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method queryNorthBoundRequestCatalogDbNestedTest.
@Test
public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "VNF-Macro-Replace", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB");
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance", "Vnf", false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance", WorkflowType.VNF, false, "my-custom-cloud-owner");
assertEquals(flows.get(0).getFlowName(), "AAICheckVnfInMaintBB");
assertEquals(flows.get(1).getFlowName(), "AAISetVnfInMaintBB");
assertEquals(flows.get(2).getFlowName(), "DeactivateVfModuleBB");
assertEquals(flows.get(3).getFlowName(), "DeleteVfModuleBB");
assertEquals(flows.get(4).getFlowName(), "DeactivateVnfBB");
assertEquals(flows.get(5).getFlowName(), "CreateVfModuleBB");
assertEquals(flows.get(6).getFlowName(), "ActivateVfModuleBB");
assertEquals(flows.get(7).getFlowName(), "ActivateVnfBB");
assertEquals(flows.get(8).getFlowName(), "SDNOVnfHealthCheckBB");
assertEquals(flows.get(9).getFlowName(), "AAIUnsetVnfInMaintBB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteNetworkDeleteTest.
@Test
public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "Network";
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v6/networks/123");
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
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, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class ExecuteBuildingBlockBuilderTest method verifyLackOfNullPointerExceptionForNullResource.
@Test
public void verifyLackOfNullPointerExceptionForNullResource() {
ExecuteBuildingBlock result = null;
try {
result = executeBBBuilder.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, false, null, null, null, false, null, null, true, null);
} catch (NullPointerException e) {
fail("NullPointerException should not be thrown when 'resource' is null");
}
assertNotNull(result);
}
use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.
the class WorkflowAction method selectExecutionList.
public void selectExecutionList(DelegateExecution execution) throws Exception {
try {
fillExecutionDefault(execution);
final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
String uri = (String) execution.getVariable(BBConstants.G_URI);
boolean isResume = isUriResume(uri);
final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId);
WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
RequestDetails requestDetails = sIRequest.getRequestDetails();
String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds);
WorkflowType resourceType = resource.getResourceType();
String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
List<ExecuteBuildingBlock> flowsToExecute;
if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
String errorMessage = "Could not resume Macro flow. Error loading execution path.";
flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
} else if (isALaCarte && isResume) {
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());
List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW);
final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION);
final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
if (isALaCarte) {
flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction, resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds, requestDetails, resourceId, vnfType, apiVersion);
} else {
flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction, execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner, serviceType, requestId, apiVersion, vnfType, requestDetails);
}
}
// enable it.
if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
for (Map<String, Object> params : userParams) {
if (params.containsKey(HOMINGSOLUTION)) {
execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION)));
}
}
}
if (CollectionUtils.isEmpty(flowsToExecute)) {
throw new IllegalStateException("Macro did not come up with a valid execution path.");
}
List<String> flowNames = new ArrayList<>();
logger.info("List of BuildingBlocks to execute:");
flowsToExecute.forEach(ebb -> {
logger.info(ebb.getBuildingBlock().getBpmnFlowName());
flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
});
if (!isResume) {
bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute);
}
setExecutionVariables(execution, flowsToExecute, flowNames);
} catch (Exception ex) {
if (!(execution.hasVariable("WorkflowException") || execution.hasVariable("WorkflowExceptionExceptionMessage"))) {
buildAndThrowException(execution, "Exception while setting execution list. ", ex);
} else {
throw ex;
}
}
}
Aggregations