use of io.automatiko.engine.workflow.base.instance.impl.demo.MockDataWorkItemHandler in project automatiko-engine by automatiko-io.
the class WorkItemTest method testMockDataWorkItemHandlerCustomFunction.
@Test
public void testMockDataWorkItemHandlerCustomFunction() {
String processId = "org.company.actions";
String workName = "Unnexistent Task";
ExecutableProcess process = getWorkItemProcess(processId, workName);
InternalProcessRuntime ksession = createProcessRuntime(process);
ksession.getWorkItemManager().registerWorkItemHandler(workName, new MockDataWorkItemHandler((input) -> {
Map<String, Object> output = new HashMap<String, Object>();
if ("John Doe".equals(input.get("Comment"))) {
output.put("Result", "one");
} else {
output.put("Result", "two");
}
return output;
}));
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("UserName", "John Doe");
parameters.put("Person", new Person("John Doe"));
ProcessInstance processInstance = ksession.startProcess("org.company.actions", parameters);
Object numberVariable = ((WorkflowProcessInstance) processInstance).getVariable("MyObject");
assertNotNull(numberVariable);
assertEquals("one", numberVariable);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
parameters = new HashMap<String, Object>();
parameters.put("UserName", "John Doe");
parameters.put("Person", new Person("John Deen"));
processInstance = ksession.startProcess("org.company.actions", parameters);
numberVariable = ((WorkflowProcessInstance) processInstance).getVariable("MyObject");
assertNotNull(numberVariable);
assertEquals("two", numberVariable);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
use of io.automatiko.engine.workflow.base.instance.impl.demo.MockDataWorkItemHandler in project automatiko-engine by automatiko-io.
the class WorkItemTest method testMockDataWorkItemHandler.
@Test
public void testMockDataWorkItemHandler() {
String processId = "org.company.actions";
String workName = "Unnexistent Task";
ExecutableProcess process = getWorkItemProcess(processId, workName);
InternalProcessRuntime ksession = createProcessRuntime(process);
Map<String, Object> output = new HashMap<String, Object>();
output.put("Result", "test");
ksession.getWorkItemManager().registerWorkItemHandler(workName, new MockDataWorkItemHandler(output));
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("UserName", "John Doe");
parameters.put("Person", new Person("John Doe"));
ProcessInstance processInstance = ksession.startProcess("org.company.actions", parameters);
Object numberVariable = ((WorkflowProcessInstance) processInstance).getVariable("MyObject");
assertNotNull(numberVariable);
assertEquals("test", numberVariable);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Aggregations