Search in sources :

Example 1 with Person

use of org.jbpm.persistence.session.objects.Person in project jbpm by kiegroup.

the class WorkItemPersistenceTest method testCancelNonRegisteredWorkItemHandler.

@Test
@Ignore
public void testCancelNonRegisteredWorkItemHandler() {
    String processId = "org.drools.actions";
    String workName = "Unnexistent Task";
    RuleFlowProcess process = getWorkItemProcess(processId, workName);
    KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    ((KnowledgeBaseImpl) kbase).addProcess(process);
    KieSession ksession = createSession(kbase);
    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.drools.actions", parameters);
    long processInstanceId = processInstance.getId();
    Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    ksession.getWorkItemManager().registerWorkItemHandler(workName, null);
    try {
        ksession.abortProcessInstance(processInstanceId);
        Assert.fail("should fail if WorkItemHandler for" + workName + "is not registered");
    } catch (WorkItemHandlerNotFoundException wihnfe) {
    }
    Assert.assertEquals(ProcessInstance.STATE_ABORTED, processInstance.getState());
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) HashMap(java.util.HashMap) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) WorkItemHandlerNotFoundException(org.drools.core.WorkItemHandlerNotFoundException) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.persistence.session.objects.Person) Ignore(org.junit.Ignore) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 WorkItemHandlerNotFoundException (org.drools.core.WorkItemHandlerNotFoundException)1 KnowledgeBaseImpl (org.drools.core.impl.KnowledgeBaseImpl)1 Person (org.jbpm.persistence.session.objects.Person)1 DoNothingWorkItemHandler (org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler)1 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)1 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 KieSession (org.kie.api.runtime.KieSession)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1