Search in sources :

Example 56 with TestWorkItemHandler

use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.

the class StructureRefTest method testDefaultObjectStructureRef.

@Test
public void testDefaultObjectStructureRef() throws Exception {
    String value = "simple text for testing";
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-DefaultObjectStructureRef.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("StructureRef");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    Map<String, Object> res = new HashMap<String, Object>();
    res.put("testHT", value);
    ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) StartEventTest(org.jbpm.bpmn2.StartEventTest) Test(org.junit.Test)

Example 57 with TestWorkItemHandler

use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.

the class StructureRefTest method testIntegerStructureRef.

@Test
public void testIntegerStructureRef() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntegerStructureRef.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("StructureRef");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    Map<String, Object> res = new HashMap<String, Object>();
    res.put("testHT", "25");
    ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) StartEventTest(org.jbpm.bpmn2.StartEventTest) Test(org.junit.Test)

Example 58 with TestWorkItemHandler

use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.

the class StructureRefTest method testNoStructureRef.

@Test
public void testNoStructureRef() throws Exception {
    Person person = new Person();
    person.setId(1L);
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-NoStructureRef.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("StructureRef");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    Map<String, Object> res = new HashMap<String, Object>();
    res.put("testHT", person);
    ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.bpmn2.objects.Person) StartEventTest(org.jbpm.bpmn2.StartEventTest) Test(org.junit.Test)

Example 59 with TestWorkItemHandler

use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.

the class StructureRefTest method testStringStructureRef.

@Test
public void testStringStructureRef() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-StringStructureRef.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("StructureRef");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    Map<String, Object> res = new HashMap<String, Object>();
    res.put("testHT", "test value");
    ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) StartEventTest(org.jbpm.bpmn2.StartEventTest) Test(org.junit.Test)

Example 60 with TestWorkItemHandler

use of org.jbpm.bpmn2.objects.TestWorkItemHandler in project jbpm by kiegroup.

the class StructureRefTest method testObjectStructureRef.

@Test
public void testObjectStructureRef() throws Exception {
    String personAsXml = "<org.jbpm.bpmn2.objects.Person><id>1</id><name>john</name></org.jbpm.bpmn2.objects.Person>";
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-ObjectStructureRef.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("StructureRef");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    Map<String, Object> res = new HashMap<String, Object>();
    res.put("testHT", personAsXml);
    ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) StartEventTest(org.jbpm.bpmn2.StartEventTest) Test(org.junit.Test)

Aggregations

TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)141 Test (org.junit.Test)138 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)134 KieBase (org.kie.api.KieBase)131 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)96 WorkItem (org.kie.api.runtime.process.WorkItem)91 HashMap (java.util.HashMap)72 KieSession (org.kie.api.runtime.KieSession)37 DefaultProcessEventListener (org.kie.api.event.process.DefaultProcessEventListener)27 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)23 ArrayList (java.util.ArrayList)21 ProcessEventListener (org.kie.api.event.process.ProcessEventListener)14 StartEventTest (org.jbpm.bpmn2.StartEventTest)13 StatefulKnowledgeSession (org.kie.internal.runtime.StatefulKnowledgeSession)10 CommandBasedStatefulKnowledgeSession (org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession)8 Person (org.jbpm.bpmn2.objects.Person)8 WorkflowProcessInstance (org.jbpm.workflow.instance.WorkflowProcessInstance)8 ProcessNodeLeftEvent (org.kie.api.event.process.ProcessNodeLeftEvent)8 ProcessStartedEvent (org.kie.api.event.process.ProcessStartedEvent)7 CountDownLatch (java.util.concurrent.CountDownLatch)6