use of org.onap.so.bpmn.common.workflow.context.WorkflowContext 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.WorkflowContext in project so by onap.
the class WorkflowAsyncResource method waitForResponse.
protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception {
String requestId = getRequestId(inputVariables);
long currentWaitTime = 0;
long waitTime = getWaitTime();
logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime);
while (waitTime > currentWaitTime) {
Thread.sleep(workflowPollInterval);
currentWaitTime = currentWaitTime + workflowPollInterval;
WorkflowContext foundContext = contextHolder.getWorkflowContext(requestId);
if (foundContext != null) {
contextHolder.remove(foundContext);
return buildResponse(foundContext);
}
}
throw new Exception("TimeOutOccured in WorkflowAsyncResource.waitForResponse for time " + waitTime + "ms");
}
Aggregations