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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations