use of org.onap.so.bpmn.common.DelegateExecutionImpl in project so by onap.
the class SerializationTest method testSerializationOfAllPojos.
@Test
public void testSerializationOfAllPojos() throws IOException {
GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
DelegateExecution execution = new ExecutionImpl();
execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
System.out.println(execution.getVariables());
BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
assertEquals(true, isSerializable);
}
use of org.onap.so.bpmn.common.DelegateExecutionImpl in project so by onap.
the class BuildingBlockValidatorRunnerTest method testValidate.
@Test
public void testValidate() {
BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
execution.setVariable("testProcessKey", "1234");
try {
runner.preValidate("test", execution);
fail("exception not thrown");
} catch (BpmnError e) {
WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
assertEquals("Failed Validations:\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorOne: my-error-one", workflowException.getErrorMessage());
}
runner.preValidate("test2", mock(BuildingBlockExecution.class));
}
use of org.onap.so.bpmn.common.DelegateExecutionImpl in project so by onap.
the class UnassignServiceInstanceBBTest method sunnyDayUnassignServiceInstanceSDNC.
@Test
public void sunnyDayUnassignServiceInstanceSDNC() throws InterruptedException {
mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
BuildingBlockExecution bbe = new DelegateExecutionImpl(new ExecutionImpl());
variables.put("gBuildingBlockExecution", bbe);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignServiceInstanceBB", variables);
assertThat(pi).isNotNull();
assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignServiceInstanceBB", "Task_SdncUnassignServiceInstance", "CallActivity_sdncHandlerCall", "Task_AAIDeleteServiceInstance", "End_UnassignServiceInstanceBB");
assertThat(pi).isEnded();
}
use of org.onap.so.bpmn.common.DelegateExecutionImpl in project so by onap.
the class WorkflowActionBBTasks method selectBB.
public void selectBB(DelegateExecution execution) {
try {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
execution.setVariable("MacroRollback", false);
try {
flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
} catch (NullPointerException ex) {
workflowAction.buildAndThrowException(execution, "Error in FlowManipulator Modify Flows", ex);
}
int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
boolean completed = false;
if (currentSequence < flowsToExecute.size()) {
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence);
execution.setVariable("buildingBlock", ebb);
execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1);
} else {
completed = true;
}
execution.setVariable(COMPLETED, completed);
} catch (Exception e) {
workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e);
}
}
use of org.onap.so.bpmn.common.DelegateExecutionImpl in project so by onap.
the class WorkflowActionBBTasks method postProcessingExecuteBB.
public void postProcessingExecuteBB(DelegateExecution execution) {
try {
List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
String handlingCode = (String) execution.getVariable(HANDLINGCODE);
final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
int currentSequence = (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
logger.debug("Current Sequence: {}", currentSequence);
if (currentSequence >= flowsToExecute.size()) {
execution.setVariable(COMPLETED, true);
}
ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1);
String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName();
if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) {
postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute);
}
flowManipulatorListenerRunner.postModifyFlows(flowsToExecute, new DelegateExecutionImpl(execution));
} catch (Exception ex) {
logger.error("Exception in postProcessingExecuteBB", ex);
workflowAction.buildAndThrowException(execution, "Failed to post process Execute BB");
}
}
Aggregations