Search in sources :

Example 1 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class GenericCDSProcessingBB method run.

@Override
public void run(ControllerContext<BuildingBlockExecution> context) {
    BuildingBlockExecution obj = context.getExecution();
    cdsDispather.constructExecutionServiceInputObjectBB(obj);
    cdsDispather.sendRequestToCDSClientBB(obj);
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution)

Example 2 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class GenericPnfCDSControllerRunnableBB method prepare.

@Override
public void prepare(ControllerContext<BuildingBlockExecution> controllerContext) {
    BuildingBlockExecution buildingBlockExecution = controllerContext.getExecution();
    final AbstractCDSPropertiesBean abstractCDSPropertiesBean = prepareAndSetCdsPropertyBean(buildingBlockExecution);
    buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)

Example 3 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution in project so by onap.

the class ManualHandlingTasks method setFalloutTaskVariables.

public void setFalloutTaskVariables(DelegateTask task) {
    DelegateExecution execution = task.getExecution();
    try {
        logger.debug("Setting fallout task variables:");
        String taskId = task.getId();
        logger.debug("taskId is: " + taskId);
        String type = TASK_TYPE_FALLOUT;
        BuildingBlockExecution gBuildingBlockExecution = (BuildingBlockExecution) execution.getVariable(G_BUILDING_BLOCK_EXECUTION);
        WorkflowException workflowException = (WorkflowException) execution.getVariable(WORKFLOW_EXCEPTION);
        String nfRole = (String) execution.getVariable(RAINY_DAY_VNF_TYPE);
        logger.debug(TASK_VARIABLE_NFROLE + ": " + nfRole);
        String subscriptionServiceType = (String) execution.getVariable(RAINY_DAY_SERVICE_TYPE);
        logger.debug(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE + ": " + subscriptionServiceType);
        String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID);
        logger.debug(TASK_VARIABLE_ORIGINAL_REQUEST_ID + ": " + originalRequestId);
        String originalRequestorId = gBuildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getRequestorId();
        logger.debug(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID + ": " + originalRequestorId);
        String description = "Manual user task to handle a failure of a BB execution";
        logger.debug(TASK_VARIABLE_DESCRIPTION + ": " + description);
        String taskTimeout = (String) gBuildingBlockExecution.getVariable(TASK_TIMEOUT);
        String timeout = Date.from((new Date()).toInstant().plus(Duration.parse(taskTimeout))).toGMTString();
        logger.debug(TASK_VARIABLE_TIMEOUT + ": " + timeout);
        String errorSource = ASTERISK;
        if (workflowException != null && workflowException.getExtSystemErrorSource() != null) {
            errorSource = workflowException.getExtSystemErrorSource().toString();
        }
        logger.debug(TASK_VARIABLE_ERROR_SOURCE + ": " + errorSource);
        String errorCode = ASTERISK;
        if (workflowException != null) {
            errorCode = workflowException.getErrorCode() + "";
        }
        logger.debug(TASK_VARIABLE_ERROR_CODE + ": " + errorCode);
        String errorMessage = ASTERISK;
        if (workflowException != null) {
            errorMessage = workflowException.getErrorMessage();
        }
        logger.debug(TASK_VARIABLE_ERROR_MESSAGE + ": " + errorMessage);
        String buildingBlockName = gBuildingBlockExecution.getFlowToBeCalled();
        logger.debug(TASK_VARIABLE_BUILDING_BLOCK_NAME + ": " + buildingBlockName);
        String buildingBlockStep = ASTERISK;
        if (workflowException != null) {
            buildingBlockStep = workflowException.getWorkStep();
        }
        execution.setVariable(WORKSTEP, buildingBlockStep);
        logger.debug(TASK_VARIABLE_BUILDING_BLOCK_STEP + ": " + buildingBlockStep);
        String validResponses = this.environment.getProperty(validResponsesPath);
        logger.debug(TASK_VARIABLE_VALID_RESPONSES + ": " + validResponses);
        Map<String, String> taskVariables = new HashMap<>();
        taskVariables.put(TASK_VARIABLE_TYPE, type);
        taskVariables.put(TASK_VARIABLE_NFROLE, nfRole);
        taskVariables.put(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE, subscriptionServiceType);
        taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUEST_ID, originalRequestId);
        taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID, originalRequestorId);
        taskVariables.put(TASK_VARIABLE_ERROR_SOURCE, errorSource);
        taskVariables.put(TASK_VARIABLE_ERROR_CODE, errorCode);
        taskVariables.put(TASK_VARIABLE_ERROR_MESSAGE, errorMessage);
        taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_NAME, buildingBlockName);
        taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_STEP, buildingBlockStep);
        taskVariables.put(TASK_VARIABLE_VALID_RESPONSES, validResponses);
        taskVariables.put(TASK_VARIABLE_TIMEOUT, timeout);
        taskVariables.put(TASK_VARIABLE_DESCRIPTION, description);
        TaskService taskService = execution.getProcessEngineServices().getTaskService();
        taskService.setVariablesLocal(taskId, taskVariables);
        logger.debug("successfully created fallout task: " + taskId);
    } catch (BpmnError e) {
        logger.debug(BPMN_EXCEPTION + e.getMessage());
        throw e;
    } catch (Exception ex) {
        String msg = "Exception in setFalloutTaskVariables " + ex.getMessage();
        logger.debug(msg);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
    }
}
Also used : BuildingBlockExecution(org.onap.so.bpmn.common.BuildingBlockExecution) HashMap(java.util.HashMap) TaskService(org.camunda.bpm.engine.TaskService) WorkflowException(org.onap.so.bpmn.core.WorkflowException) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) Date(java.util.Date) WorkflowException(org.onap.so.bpmn.core.WorkflowException) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Example 4 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution 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 5 with BuildingBlockExecution

use of org.onap.so.bpmn.common.BuildingBlockExecution 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)

Aggregations

BuildingBlockExecution (org.onap.so.bpmn.common.BuildingBlockExecution)39 Test (org.junit.Test)27 HashMap (java.util.HashMap)10 DelegateExecutionImpl (org.onap.so.bpmn.common.DelegateExecutionImpl)10 DelegateExecutionFake (org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake)7 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)6 ArrayList (java.util.ArrayList)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)4 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)4 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)4 List (java.util.List)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)3 AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3