use of io.automatiko.engine.workflow.base.instance.impl.demo.DoNothingWorkItemHandler in project automatiko-engine by automatiko-io.
the class WorkItemTest method testCancelNonRegisteredWorkItemHandler.
@Test
public void testCancelNonRegisteredWorkItemHandler() {
String processId = "org.company.actions";
String workName = "Unnexistent Task";
ExecutableProcess process = getWorkItemProcess(processId, workName);
InternalProcessRuntime ksession = createProcessRuntime(process);
ksession.getWorkItemManager().registerWorkItemHandler(workName, new DoNothingWorkItemHandler());
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);
String processInstanceId = processInstance.getId();
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
ksession.getWorkItemManager().registerWorkItemHandler(workName, null);
try {
ksession.abortProcessInstance(processInstanceId);
fail("should fail if WorkItemHandler for" + workName + "is not registered");
} catch (WorkItemHandlerNotFoundException wihnfe) {
}
assertEquals(ProcessInstance.STATE_ABORTED, processInstance.getState());
}
Aggregations