Search in sources :

Example 1 with WorkflowResponse

use of org.onap.so.bpmn.common.workflow.context.WorkflowResponse in project so by onap.

the class WorkflowAsyncResourceTest method asyncRequestSuccess.

@Test
@Deployment(resources = { "testAsyncResource.bpmn" })
public void asyncRequestSuccess() throws InterruptedException {
    // it can be any request which asynchronously processed by the workflow
    String request = "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\">  <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\">    <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type>    <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id>    <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>";
    Map<String, String> variables = new HashMap<>();
    variables.put("testAsyncRequestMsg", request);
    variables.put("mso-request-id", UUID.randomUUID().toString());
    variables.put("mso-service-request-timeout", "5");
    WorkflowResponse workflowResponse = BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables);
    assertEquals("Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns5=\"http://org.onap/so/request/types/v1\">  <msoservtypes:service-information xmlns:msoservtypes=\"http://org.onap/so/request/types/v1\">    <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type>    <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id>    <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>", workflowResponse.getResponse());
    assertEquals(200, workflowResponse.getMessageCode());
}
Also used : HashMap(java.util.HashMap) WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with WorkflowResponse

use of org.onap.so.bpmn.common.workflow.context.WorkflowResponse in project so by onap.

the class WorkflowContextHolderTest method testProcessCallback.

@Test
public void testProcessCallback() throws Exception {
    String requestId = UUID.randomUUID().toString();
    String message = "TEST MESSATGE";
    String responseMessage = "Successfully processed request";
    int testCode = 200;
    WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
    WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
    callbackResponse.setMessage(message);
    callbackResponse.setResponse(responseMessage);
    callbackResponse.setStatusCode(testCode);
    contextHolder.processCallback("testAsyncProcess", "process-instance-id", requestId, callbackResponse);
    // same object returned
    WorkflowContext contextFound = contextHolder.getWorkflowContext(requestId);
    if (contextFound == null)
        throw new Exception("Expected to find Context Object");
    WorkflowResponse testResponse = contextFound.getWorkflowResponse();
    Assert.assertEquals(200, testResponse.getMessageCode());
    Assert.assertEquals(message, testResponse.getMessage());
    Assert.assertEquals(responseMessage, testResponse.getResponse());
}
Also used : WorkflowContextHolder(org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder) WorkflowContext(org.onap.so.bpmn.common.workflow.context.WorkflowContext) WorkflowCallbackResponse(org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse) WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse) Test(org.junit.Test)

Example 3 with WorkflowResponse

use of org.onap.so.bpmn.common.workflow.context.WorkflowResponse in project so by onap.

the class WorkflowAsyncResourceTest method startProcessInstanceByKey500Test.

@Test
public void startProcessInstanceByKey500Test() throws Exception {
    workflowResponse.setMessageCode(500);
    doReturn(workflowResponse).when(workflowAsyncResource).waitForResponse(anyMap());
    Response response = workflowAsyncResource.startProcessInstanceByKey("123", varMap);
    assertEquals(500, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse) Test(org.junit.Test)

Example 4 with WorkflowResponse

use of org.onap.so.bpmn.common.workflow.context.WorkflowResponse in project so by onap.

the class BPMNUtil method executeWorkFlow.

public static WorkflowResponse executeWorkFlow(ProcessEngineServices processEngineServices, String processKey, Map<String, String> variables) {
    VariableMapImpl variableMap = new VariableMapImpl();
    Map<String, Object> variableValueType = new HashMap<>();
    for (String key : variables.keySet()) {
        buildVariable(key, variables.get(key), variableValueType);
    }
    buildVariable("mso-service-request-timeout", "600", variableValueType);
    variableMap.put("variables", variableValueType);
    workflowResource.setProcessEngineServices4junit(processEngineServices);
    Response response = workflowResource.startProcessInstanceByKey(processKey, variableMap);
    WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
    return workflowResponse;
}
Also used : Response(javax.ws.rs.core.Response) WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse) VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) HashMap(java.util.HashMap) WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse)

Example 5 with WorkflowResponse

use of org.onap.so.bpmn.common.workflow.context.WorkflowResponse in project so by onap.

the class WorkflowAsyncResource method buildUnkownError.

private WorkflowResponse buildUnkownError(String requestId, String error) {
    WorkflowResponse response = new WorkflowResponse();
    response.setMessage(error);
    response.setResponse("UnknownError, request id:" + requestId);
    response.setMessageCode(500);
    return response;
}
Also used : WorkflowResponse(org.onap.so.bpmn.common.workflow.context.WorkflowResponse)

Aggregations

WorkflowResponse (org.onap.so.bpmn.common.workflow.context.WorkflowResponse)14 HashMap (java.util.HashMap)6 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)5 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)4 Operation (io.swagger.v3.oas.annotations.Operation)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 WorkflowException (org.onap.so.bpmn.core.WorkflowException)2 WorkflowProcessorException (org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ProcessEngineServices (org.camunda.bpm.engine.ProcessEngineServices)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)1 JSONObject (org.json.JSONObject)1