Search in sources :

Example 1 with DoNothingWorkItemHandler

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());
}
Also used : HashMap(java.util.HashMap) DoNothingWorkItemHandler(io.automatiko.engine.workflow.base.instance.impl.demo.DoNothingWorkItemHandler) WorkItemHandlerNotFoundException(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance) Person(io.automatiko.engine.workflow.process.test.Person) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)1 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)1 DoNothingWorkItemHandler (io.automatiko.engine.workflow.base.instance.impl.demo.DoNothingWorkItemHandler)1 WorkItemHandlerNotFoundException (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 WorkflowProcessInstance (io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)1 Person (io.automatiko.engine.workflow.process.test.Person)1 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1