use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class BBInputSetupPopulateMethodsTest method test_getGBBMacro_populateVfModule_shouldBeCalled.
@Test
public void test_getGBBMacro_populateVfModule_shouldBeCalled() throws Exception {
// given
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockWithVnf.json"), GeneralBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
GenericVnf aaiVnf = new GenericVnf();
aaiVnf.setModelCustomizationId("modelCustId");
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName(AssignFlows.VF_MODULE.toString()).setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(any(String.class));
// when
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
// then
verify(SPY_bbInputSetup, times(1)).populateVfModule(any(BBInputSetupParameter.class));
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class ExecuteBuildingBlockRainyDayTest method queryRainyDayTableRollbackToCreatedNoConfiguration.
@Test
public void queryRainyDayTableRollbackToCreatedNoConfiguration() throws Exception {
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
vnf.setVnfType("vnft1");
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AddFabricConfigurationBB");
rainyDayHandlerStatus.setServiceType("st1");
rainyDayHandlerStatus.setVnfType("vnft1");
rainyDayHandlerStatus.setPolicy("RollbackToCreatedNoConfiguration");
rainyDayHandlerStatus.setWorkStep(ASTERISK);
rainyDayHandlerStatus.setSecondaryPolicy("Abort");
doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AddFabricConfigurationBB", "st1", "vnft1", "7000", "*", "errorMessage", "*");
executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
assertEquals("RollbackToCreatedNoConfiguration", delegateExecution.getVariable("handlingCode"));
assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState"));
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class ExecuteBuildingBlockRainyDayTest method before.
@Before
public void before() {
serviceInstance = setServiceInstance();
customer = setCustomer();
vnf = setGenericVnf();
BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName("AssignServiceInstanceBB");
ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock);
delegateExecution.setVariable("gBBInput", gBBInput);
delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
delegateExecution.setVariable("lookupKeyMap", lookupKeyMap);
delegateExecution.setVariable("WorkflowException", new WorkflowException("processKey", 7000, "errorMessage"));
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class ExecuteActivityTest method buildBuildingBlock_Test.
@Test
public void buildBuildingBlock_Test() {
BuildingBlock bb = executeActivity.buildBuildingBlock("testActivityName");
assertEquals(bb.getBpmnFlowName(), "testActivityName");
assertEquals(bb.getKey(), "");
}
use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class WorkflowActionBBTasks method rollbackExecutionPath.
/**
* Rollback will only handle Create/Activate/Assign Macro flows. Execute layer will rollback the flow its currently
* working on.
*/
public void rollbackExecutionPath(DelegateExecution execution) {
final String action = (String) execution.getVariable(BBConstants.G_ACTION);
final String resourceName = (String) execution.getVariable("resourceName");
if (!(boolean) execution.getVariable("isRollback")) {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
List<ExecuteBuildingBlock> flowsToExecuteChangeBBs = flowsToExecute.stream().filter(buildingBlock -> buildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")).collect(Collectors.toList());
List<ExecuteBuildingBlock> rollbackFlows = new ArrayList<>();
int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
int listSize = flowsToExecute.size();
for (int i = listSize - 1; i >= 0; i--) {
if (i > currentSequence - 1) {
flowsToExecute.remove(i);
} else {
String flowName = flowsToExecute.get(i).getBuildingBlock().getBpmnFlowName();
if (flowName.startsWith("Assign")) {
flowName = flowName.replaceFirst("Assign", "Unassign");
} else if (flowName.startsWith("Create")) {
flowName = flowName.replaceFirst("Create", "Delete");
} else if (flowName.startsWith("Activate")) {
flowName = flowName.replaceFirst("Activate", "Deactivate");
} else if (flowName.startsWith("Add")) {
flowName = flowName.replaceFirst("Add", "Delete");
} else if (flowName.startsWith("VNF")) {
if (flowName.startsWith("VNFSet")) {
flowName = flowName.replaceFirst("VNFSet", "VNFUnset");
} else if (flowName.startsWith("VNFLock")) {
flowName = flowName.replaceFirst("VNFLock", "VNFUnlock");
} else if (flowName.startsWith("VNFStop")) {
flowName = flowName.replaceFirst("VNFStop", "VNFStart");
} else if (flowName.startsWith("VNFQuiesce")) {
flowName = flowName.replaceFirst("VNFQuiesce", "VNFResume");
} else {
continue;
}
} else {
continue;
}
flowsToExecute.get(i).getBuildingBlock().setBpmnFlowName(flowName);
rollbackFlows.add(flowsToExecute.get(i));
}
}
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
List<ExecuteBuildingBlock> rollbackFlowsFiltered = new ArrayList<>(rollbackFlows);
if ("RollbackToAssigned".equals(handlingCode) || ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)) {
for (ExecuteBuildingBlock rollbackFlow : rollbackFlows) {
if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Unassign") && !rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration")) {
rollbackFlowsFiltered.remove(rollbackFlow);
} else if (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("Delete") && ((!rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && (ROLLBACKTOCREATED.equals(handlingCode) || ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode))) || (rollbackFlow.getBuildingBlock().getBpmnFlowName().contains("FabricConfiguration") && ROLLBACKTOCREATEDNOCONFIGURATION.equals(handlingCode)))) {
rollbackFlowsFiltered.remove(rollbackFlow);
}
}
}
List<ExecuteBuildingBlock> rollbackFlowsFilteredNonChangeBBs = new ArrayList<>();
if (action.equals(REPLACEINSTANCE) && resourceName.equals(VFMODULE)) {
for (ExecuteBuildingBlock executeBuildingBlock : rollbackFlowsFiltered) {
if (!executeBuildingBlock.getBuildingBlock().getBpmnFlowName().startsWith("Change")) {
rollbackFlowsFilteredNonChangeBBs.add(executeBuildingBlock);
}
}
rollbackFlowsFiltered.clear();
rollbackFlowsFiltered.addAll(flowsToExecuteChangeBBs);
rollbackFlowsFiltered.addAll(rollbackFlowsFilteredNonChangeBBs);
}
workflowActionBBFailure.updateRequestErrorStatusMessage(execution);
execution.setVariable("isRollbackNeeded", !rollbackFlows.isEmpty());
execution.setVariable("flowsToExecute", rollbackFlowsFiltered);
execution.setVariable(HANDLINGCODE, "PreformingRollback");
execution.setVariable("isRollback", true);
execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0);
execution.setVariable(RETRY_COUNT, 0);
} else {
workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state.");
}
}
Aggregations