Search in sources :

Example 1 with DelegateExecutionImpl

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);
}
Also used : GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) HashMap(java.util.HashMap) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) File(java.io.File) ResourceKey(org.onap.so.bpmn.servicedecomposition.entities.ResourceKey) Test(org.junit.Test)

Example 2 with DelegateExecutionImpl

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));
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) WorkflowException(org.onap.so.bpmn.core.WorkflowException) DelegateExecutionFake(org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake) BpmnError(org.camunda.bpm.engine.delegate.BpmnError) Test(org.junit.Test)

Example 3 with DelegateExecutionImpl

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();
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) BaseBPMNTest(org.onap.so.bpmn.BaseBPMNTest)

Example 4 with DelegateExecutionImpl

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);
    }
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) EntityNotFoundException(javax.persistence.EntityNotFoundException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 5 with DelegateExecutionImpl

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");
    }
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) DelegateExecutionImpl(org.onap.so.bpmn.common.DelegateExecutionImpl) ArrayList(java.util.ArrayList) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) EntityNotFoundException(javax.persistence.EntityNotFoundException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

DelegateExecutionImpl (org.onap.so.bpmn.common.DelegateExecutionImpl)29 DelegateExecutionFake (org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake)17 BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)11 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)9 Before (org.junit.Before)9 Test (org.junit.Test)9 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)8 ExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl)6 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)2 WorkflowException (org.onap.so.bpmn.core.WorkflowException)2 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)2 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)2 ExtractPojosForBB (org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB)2