Search in sources :

Example 6 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class AbstractCDSProcessingBBUtils method constructExecutionServiceInputObject.

/**
 * Extracting data from execution object and building the ExecutionServiceInput Object
 *
 * @param execution DelegateExecution object
 */
public void constructExecutionServiceInputObject(DelegateExecution execution) {
    logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest for DelegateExecution object.");
    try {
        AbstractCDSPropertiesBean executionObject = (AbstractCDSPropertiesBean) execution.getVariable(EXECUTION_OBJECT);
        ExecutionServiceInput executionServiceInput = prepareExecutionServiceInput(executionObject);
        execution.setVariable(EXEC_INPUT, executionServiceInput);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) BadResponseException(org.onap.so.client.exception.BadResponseException) PreconditionFailedException(org.onap.so.client.PreconditionFailedException)

Example 7 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class AbstractCDSProcessingBBUtils method sendRequestToCDSClient.

/**
 * get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period
 *
 * @param execution DelegateExecution object
 */
public void sendRequestToCDSClient(DelegateExecution execution) {
    logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient for DelegateExecution object.");
    try {
        ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution.getVariable(EXEC_INPUT);
        CDSResponse cdsResponse = getCdsResponse(executionServiceInput);
        execution.setVariable(CDS_STATUS, cdsResponse.status);
        if (cdsResponse.payload != null) {
            String payload = JsonFormat.printer().print(cdsResponse.payload);
            execution.setVariable(RESPONSE_PAYLOAD, payload);
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) BadResponseException(org.onap.so.client.exception.BadResponseException) PreconditionFailedException(org.onap.so.client.PreconditionFailedException)

Example 8 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class AbstractCDSProcessingBBUtils method constructExecutionServiceInputObjectBB.

/**
 * Extracting data from execution object and building the ExecutionServiceInput Object
 *
 * @param execution BuildingBlockExecution object
 */
public void constructExecutionServiceInputObjectBB(BuildingBlockExecution execution) {
    logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest for BuildingBlockExecution object.");
    try {
        AbstractCDSPropertiesBean executionObject = execution.getVariable(EXECUTION_OBJECT);
        ExecutionServiceInput executionServiceInput = prepareExecutionServiceInput(executionObject);
        execution.setVariable(EXEC_INPUT, executionServiceInput);
        logger.debug("Input payload: " + executionServiceInput.getPayload());
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : AbstractCDSPropertiesBean(org.onap.so.client.cds.beans.AbstractCDSPropertiesBean) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) BadResponseException(org.onap.so.client.exception.BadResponseException) PreconditionFailedException(org.onap.so.client.PreconditionFailedException)

Example 9 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class CreateVcpeResCustServiceSimplifiedTest method workflow_validInput_expectedOuput.

@Test
public void workflow_validInput_expectedOuput() throws InterruptedException {
    mockCatalogDb();
    mockRequestDb();
    mockAai();
    mockDmaapForPnf();
    grpcNettyServer.resetList();
    final String msoRequestId = UUID.randomUUID().toString();
    executionVariables.put("mso-request-id", msoRequestId);
    ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
    int waitCount = 10;
    while (!isProcessInstanceEnded() && waitCount >= 0) {
        Thread.sleep(WORKFLOW_WAIT_TIME);
        waitCount--;
    }
    assertThat(pi).isEnded().hasPassedInOrder("createVCPE_startEvent", "preProcessRequest_ScriptTask", "sendSyncAckResponse_ScriptTask", "ScriptTask_0cdtchu", "DecomposeService", "ScriptTask_0lpv2da", "ScriptTask_1y241p8", "CallActivity_1vc4jeh", "ScriptTask_1y5lvl7", "GeneratePnfUuid", "Task_14l19kv", "Pnf_Con", "setPONR_ScriptTask", "postProcessAndCompletionRequest_ScriptTask", "callCompleteMsoProcess_CallActivity", "ScriptTask_2", "CreateVCPE_EndEvent");
    List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
    assertThat(detailedMessages.size() == 2);
    int count = 0;
    try {
        for (ExecutionServiceInput eSI : detailedMessages) {
            if ("config-assign".equals(eSI.getActionIdentifiers().getActionName())) {
                checkConfigAssign(eSI, msoRequestId);
                count++;
            }
            if ("config-deploy".equals(eSI.getActionIdentifiers().getActionName())) {
                checkConfigDeploy(eSI, msoRequestId);
                count++;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("ConfigAssign/deploy request exception", e);
    }
    assertThat(count == 2);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) IOException(java.io.IOException) BaseBPMNTest(org.onap.so.BaseBPMNTest) Test(org.junit.Test)

Example 10 with ExecutionServiceInput

use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.

the class GenericPnfSoftwareUpgradeTest method workflow_validInput_expectedOutput.

@Test
public void workflow_validInput_expectedOutput() throws InterruptedException {
    mockCatalogDb();
    mockRequestDb();
    mockAai();
    grpcNettyServer.resetList();
    final String msoRequestId = UUID.randomUUID().toString();
    executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
    final String testBusinessKey = UUID.randomUUID().toString();
    logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
    ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
    int waitCount = 10;
    while (!isProcessInstanceEnded() && waitCount >= 0) {
        Thread.sleep(WORKFLOW_WAIT_TIME);
        waitCount--;
    }
    // Layout is to reflect the bpmn visual layout
    assertThat(pi).isStarted().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", "ScriptTask_10klpg8", "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", "ExclusiveGateway_0v3l3wv", "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", "ExclusiveGateway_1ny9b1z", "ScriptTask_1igtc83", "CallActivity_0o1mi8u", "softwareUpgrade_endEvent");
    List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
    assertEquals(4, detailedMessages.size());
    int count = 0;
    try {
        for (ExecutionServiceInput eSI : detailedMessages) {
            for (String action : actionNames) {
                if (action.equals(eSI.getActionIdentifiers().getActionName()) && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
                    checkWithActionName(eSI, action);
                    count++;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("GenericPnfSoftwareUpgrade request exception", e);
    }
    assertTrue(count == actionNames.length);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExecutionServiceInput(org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput) IOException(java.io.IOException) BaseBPMNTest(org.onap.so.BaseBPMNTest) Test(org.junit.Test)

Aggregations

ExecutionServiceInput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput)14 Test (org.junit.Test)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 BaseBPMNTest (org.onap.so.BaseBPMNTest)5 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 IOException (java.io.IOException)4 PreconditionFailedException (org.onap.so.client.PreconditionFailedException)4 BadResponseException (org.onap.so.client.exception.BadResponseException)4 StreamObserver (io.grpc.stub.StreamObserver)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ExecutionServiceOutput (org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput)3 BluePrintProcessingServiceImplBase (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase)2 AbstractCDSPropertiesBean (org.onap.so.client.cds.beans.AbstractCDSPropertiesBean)2 PostConstruct (javax.annotation.PostConstruct)1 Before (org.junit.Before)1 ActionIdentifiers (org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers)1 BluePrintProcessingServiceStub (org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub)1