Search in sources :

Example 11 with TestWorkItemHandler

use of org.jbpm.integrationtests.handler.TestWorkItemHandler in project jbpm by kiegroup.

the class ProcessDynamicNodeTest method testAddDynamicWorkItem.

@Test
public void testAddDynamicWorkItem() {
    Reader source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "         type=\"RuleFlow\" name=\"ruleflow\" id=\"org.drools.dynamic\" package-name=\"org.drools\" >\n" + "\n" + "  <header>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <dynamic id=\"2\" name=\"DynamicNode\" >\n" + "      <nodes>\n" + "        <actionNode id=\"1\" name=\"Action\" >\n" + "          <action type=\"expression\" dialect=\"mvel\" >System.out.println(\"Action\");</action>\n" + "        </actionNode>\n" + "      </nodes>\n" + "      <connections>\n" + "      </connections>\n" + "      <in-ports/>\n" + "      <out-ports/>\n" + "    </dynamic>\n" + "    <end id=\"3\" name=\"End\" />\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"1\" to=\"2\" />\n" + "    <connection from=\"2\" to=\"3\" />\n" + "  </connections>\n" + "</process>");
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add(ResourceFactory.newReaderResource(source), ResourceType.DRF);
    KieBase kbase = kbuilder.newKieBase();
    KieSession ksession = kbase.newKieSession();
    KieRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    // start a new process instance
    ProcessInstance processInstance = (ProcessInstance) ksession.startProcess("org.drools.dynamic");
    DynamicNodeInstance dynamicContext = (DynamicNodeInstance) ((WorkflowProcessInstance) processInstance).getNodeInstances().iterator().next();
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("TaskName", "Dynamic Task");
    assertNull(handler.getWorkItem());
    assertEquals(0, dynamicContext.getNodeInstances().size());
    DynamicUtils.addDynamicWorkItem(dynamicContext, ksession, "Human Task", parameters);
    assertNotNull(handler.getWorkItem());
    assertEquals(1, dynamicContext.getNodeInstances().size());
    logger.close();
}
Also used : TestWorkItemHandler(org.jbpm.integrationtests.handler.TestWorkItemHandler) DynamicNodeInstance(org.jbpm.workflow.instance.node.DynamicNodeInstance) HashMap(java.util.HashMap) Reader(java.io.Reader) StringReader(java.io.StringReader) KieRuntimeLogger(org.kie.api.logger.KieRuntimeLogger) KnowledgeBuilder(org.kie.internal.builder.KnowledgeBuilder) KieBase(org.kie.api.KieBase) StringReader(java.io.StringReader) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.jbpm.process.instance.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 12 with TestWorkItemHandler

use of org.jbpm.integrationtests.handler.TestWorkItemHandler in project jbpm by kiegroup.

the class ProcessHumanTaskTest method testHumanTaskCancel2.

@Test
public void testHumanTaskCancel2() {
    Reader source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.humantask\" package-name=\"org.drools\" version=\"1\" >\n" + "\n" + "  <header>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <humanTask id=\"2\" name=\"HumanTask\" >\n" + "      <work name=\"Human Task\" >\n" + "        <parameter name=\"ActorId\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>John Doe</value>\n" + "        </parameter>\n" + "        <parameter name=\"TaskName\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>Do something</value>\n" + "        </parameter>\n" + "        <parameter name=\"Priority\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "        <parameter name=\"Comment\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "      </work>\n" + "      <onExit>\n" + "        <action type=\"expression\" name=\"Cancel\" dialect=\"java\" >((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();</action>\n" + "      </onExit>\n" + "    </humanTask>\n" + "    <end id=\"3\" name=\"End\" />\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"1\" to=\"2\" />\n" + "    <connection from=\"2\" to=\"3\" />\n" + "  </connections>\n" + "\n" + "</process>");
    builder.addRuleFlow(source);
    KieSession workingMemory = createKieSession(builder.getPackages());
    TestWorkItemHandler handler = new TestWorkItemHandler();
    workingMemory.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = (ProcessInstance) workingMemory.startProcess("org.drools.humantask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    WorkItem workItem = handler.getWorkItem();
    assertNotNull(workItem);
    workingMemory.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    assertFalse(handler.isAborted());
}
Also used : TestWorkItemHandler(org.jbpm.integrationtests.handler.TestWorkItemHandler) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.jbpm.process.instance.ProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 13 with TestWorkItemHandler

use of org.jbpm.integrationtests.handler.TestWorkItemHandler in project jbpm by kiegroup.

the class ProcessHumanTaskTest method testSwimlane.

@Test
public void testSwimlane() {
    Reader source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.humantask\" package-name=\"org.drools\" version=\"1\" >\n" + "\n" + "  <header>\n" + "    <swimlanes>\n" + "      <swimlane name=\"actor1\" />\n" + "    </swimlanes>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <humanTask id=\"2\" name=\"HumanTask\" swimlane=\"actor1\" >\n" + "      <work name=\"Human Task\" >\n" + "        <parameter name=\"ActorId\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>John Doe</value>\n" + "        </parameter>\n" + "        <parameter name=\"TaskName\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>Do something</value>\n" + "        </parameter>\n" + "        <parameter name=\"Priority\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "        <parameter name=\"Comment\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "      </work>\n" + "      <mapping type=\"out\" from=\"ActorId\" to=\"ActorId\" />" + "    </humanTask>\n" + "    <humanTask id=\"3\" name=\"HumanTask\" swimlane=\"actor1\" >\n" + "      <work name=\"Human Task\" >\n" + "        <parameter name=\"ActorId\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "        <parameter name=\"TaskName\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>Do something else</value>\n" + "        </parameter>\n" + "        <parameter name=\"Priority\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "        <parameter name=\"Comment\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "      </work>\n" + "      <mapping type=\"out\" from=\"ActorId\" to=\"ActorId\" />" + "    </humanTask>\n" + "    <end id=\"4\" name=\"End\" />\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"1\" to=\"2\" />\n" + "    <connection from=\"2\" to=\"3\" />\n" + "    <connection from=\"3\" to=\"4\" />\n" + "  </connections>\n" + "\n" + "</process>");
    builder.addRuleFlow(source);
    KieSession workingMemory = createKieSession(builder.getPackages());
    TestWorkItemHandler handler = new TestWorkItemHandler();
    workingMemory.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = (ProcessInstance) workingMemory.startProcess("org.drools.humantask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    WorkItem workItem = handler.getWorkItem();
    assertNotNull(workItem);
    assertEquals("Do something", workItem.getParameter("TaskName"));
    assertEquals("John Doe", workItem.getParameter("ActorId"));
    Map<String, Object> results = new HashMap<String, Object>();
    results.put("ActorId", "Jane Doe");
    workingMemory.getWorkItemManager().completeWorkItem(workItem.getId(), results);
    workItem = handler.getWorkItem();
    assertNotNull(workItem);
    assertEquals("Do something else", workItem.getParameter("TaskName"));
    assertEquals("Jane Doe", workItem.getParameter("SwimlaneActorId"));
    workingMemory.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
Also used : TestWorkItemHandler(org.jbpm.integrationtests.handler.TestWorkItemHandler) HashMap(java.util.HashMap) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.jbpm.process.instance.ProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 14 with TestWorkItemHandler

use of org.jbpm.integrationtests.handler.TestWorkItemHandler in project jbpm by kiegroup.

the class ProcessHumanTaskTest method testHumanTaskCancel.

@Test
public void testHumanTaskCancel() {
    Reader source = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.humantask\" package-name=\"org.drools\" version=\"1\" >\n" + "\n" + "  <header>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <humanTask id=\"2\" name=\"HumanTask\" >\n" + "      <work name=\"Human Task\" >\n" + "        <parameter name=\"ActorId\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>John Doe</value>\n" + "        </parameter>\n" + "        <parameter name=\"TaskName\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>Do something</value>\n" + "        </parameter>\n" + "        <parameter name=\"Priority\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "        <parameter name=\"Comment\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "        </parameter>\n" + "      </work>\n" + "    </humanTask>\n" + "    <end id=\"3\" name=\"End\" />\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"1\" to=\"2\" />\n" + "    <connection from=\"2\" to=\"3\" />\n" + "  </connections>\n" + "\n" + "</process>");
    builder.addRuleFlow(source);
    KieSession workingMemory = createKieSession(builder.getPackages());
    TestWorkItemHandler handler = new TestWorkItemHandler();
    workingMemory.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    ProcessInstance processInstance = (ProcessInstance) workingMemory.startProcess("org.drools.humantask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    WorkItem workItem = handler.getWorkItem();
    assertNotNull(workItem);
    processInstance.setState(ProcessInstance.STATE_ABORTED);
    assertTrue(handler.isAborted());
}
Also used : TestWorkItemHandler(org.jbpm.integrationtests.handler.TestWorkItemHandler) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.jbpm.process.instance.ProcessInstance) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 15 with TestWorkItemHandler

use of org.jbpm.integrationtests.handler.TestWorkItemHandler in project jbpm by kiegroup.

the class ProcessMarshallingTest method testMarshallingWithHumanTaskAndRule.

@Test
public void testMarshallingWithHumanTaskAndRule() throws Exception {
    String process1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "  xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "  xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "  type=\"RuleFlow\" name=\"ruleflow\" id=\"com.sample.ruleflow\" package-name=\"com.sample\" >\n" + "\n" + "  <header>\n" + "    <imports>\n" + "      <import name=\"org.jbpm.integrationtests.test.Person\" />\n" + "    </imports>\n" + "    <swimlanes>\n" + "      <swimlane name=\"swimlane\" />\n" + "    </swimlanes>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <end id=\"4\" name=\"End\" />\n" + "    <split id=\"5\" name=\"AND\" type=\"1\" />\n" + "    <subProcess id=\"6\" name=\"SubProcess\" processId=\"com.sample.subflow\" />\n" + "    <actionNode id=\"7\" name=\"Action\" >\n" + "      <action type=\"expression\" dialect=\"mvel\" >System.out.println(\"Executing action 1\");</action>\n" + "	 </actionNode>\n" + "    <join id=\"8\" name=\"AND\" type=\"1\" />\n" + "    <actionNode id=\"9\" name=\"Action\" >\n" + "      <action type=\"expression\" dialect=\"mvel\" >System.out.println(\"Executing action 2\");</action>\n" + "    </actionNode>\n" + "    <ruleSet id=\"10\" name=\"RuleSet\" ruleFlowGroup=\"flowgroup\" />\n" + "    <milestone id=\"11\" name=\"Event Wait\" >\n" + "      <constraint type=\"rule\" dialect=\"mvel\" >Person( )</constraint>\n" + "    </milestone>\n" + "    <workItem id=\"12\" name=\"Log\" >\n" + "      <work name=\"Log\" >\n" + "        <parameter name=\"Message\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>This is a log message</value>\n" + "        </parameter>\n" + "      </work>\n" + "    </workItem>\n" + "    <composite id=\"13\" name=\"CompositeNode\" >\n" + "      <variables>\n" + "        <variable name=\"x\" >\n" + "          <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "          <value>x-value</value>\n" + "        </variable>\n" + "      </variables>\n" + "      <nodes>\n" + "        <humanTask id=\"1\" name=\"Human Task\" swimlane=\"swimlane\" >\n" + "          <work name=\"Human Task\" >\n" + "            <parameter name=\"ActorId\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "              <value>John Doe</value>\n" + "            </parameter>\n" + "            <parameter name=\"Priority\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "            </parameter>\n" + "            <parameter name=\"TaskName\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "              <value>Do something !</value>\n" + "            </parameter>\n" + "            <parameter name=\"Comment\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "            </parameter>\n" + "          </work>\n" + "        </humanTask>\n" + "        <humanTask id=\"2\" name=\"Human Task\" swimlane=\"swimlane\" >\n" + "          <work name=\"Human Task\" >\n" + "            <parameter name=\"ActorId\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "            </parameter>\n" + "            <parameter name=\"Priority\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "            </parameter>\n" + "            <parameter name=\"TaskName\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "              <value>Do something else !</value>\n" + "            </parameter>\n" + "            <parameter name=\"Comment\" >\n" + "              <type name=\"org.jbpm.process.core.datatype.impl.type.StringDataType\" />\n" + "            </parameter>\n" + "          </work>\n" + "          <mapping type=\"in\" from=\"x\" to=\"Priority\" />\n" + "        </humanTask>\n" + "      </nodes>\n" + "      <connections>\n" + "        <connection from=\"1\" to=\"2\" />\n" + "      </connections>\n" + "      <in-ports>\n" + "        <in-port type=\"DROOLS_DEFAULT\" nodeId=\"1\" nodeInType=\"DROOLS_DEFAULT\" />\n" + "      </in-ports>\n" + "      <out-ports>\n" + "        <out-port type=\"DROOLS_DEFAULT\" nodeId=\"2\" nodeOutType=\"DROOLS_DEFAULT\" />\n" + "      </out-ports>\n" + "    </composite>\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"9\" to=\"4\" />\n" + "    <connection from=\"1\" to=\"5\" />\n" + "    <connection from=\"5\" to=\"6\" />\n" + "    <connection from=\"5\" to=\"7\" />\n" + "    <connection from=\"7\" to=\"8\" />\n" + "    <connection from=\"6\" to=\"8\" />\n" + "    <connection from=\"10\" to=\"8\" />\n" + "    <connection from=\"11\" to=\"8\" />\n" + "    <connection from=\"12\" to=\"8\" />\n" + "    <connection from=\"13\" to=\"8\" />\n" + "    <connection from=\"8\" to=\"9\" />\n" + "    <connection from=\"5\" to=\"10\" />\n" + "    <connection from=\"5\" to=\"11\" />\n" + "    <connection from=\"5\" to=\"12\" />\n" + "    <connection from=\"5\" to=\"13\" />\n" + "  </connections>\n" + "\n" + "</process>\n";
    builder.addProcessFromXml(new StringReader(process1));
    String process2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n" + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n" + "         type=\"RuleFlow\" name=\"flow\" id=\"com.sample.subflow\" package-name=\"com.sample\" >\n" + "\n" + "  <header>\n" + "    <imports>\n" + "      <import name=\"org.jbpm.integrationtests.test.Person\" />\n" + "    </imports>\n" + "  </header>\n" + "\n" + "  <nodes>\n" + "    <start id=\"1\" name=\"Start\" />\n" + "    <milestone id=\"2\" name=\"Event Wait\" >\n" + "      <constraint type=\"rule\" dialect=\"mvel\" >Person( )</constraint>\n" + "    </milestone>\n" + "    <end id=\"3\" name=\"End\" />\n" + "  </nodes>\n" + "\n" + "  <connections>\n" + "    <connection from=\"1\" to=\"2\" />\n" + "    <connection from=\"2\" to=\"3\" />\n" + "  </connections>\n" + "\n" + "</process>\n";
    builder.addProcessFromXml(new StringReader(process2));
    String rule = "package com.sample\n" + "import org.jbpm.integrationtests.test.Person;\n" + "rule \"Hello\" ruleflow-group \"flowgroup\"\n" + "    when\n" + "    then\n" + "        System.out.println( \"Hello\" );\n" + "end";
    builder.addPackageFromDrl(new StringReader(rule));
    KieSession session = createKieSession(builder.getPackages());
    TestWorkItemHandler handler1 = new TestWorkItemHandler();
    session.getWorkItemManager().registerWorkItemHandler("Log", handler1);
    TestWorkItemHandler handler2 = new TestWorkItemHandler();
    session.getWorkItemManager().registerWorkItemHandler("Human Task", handler2);
    session.startProcess("com.sample.ruleflow");
    assertEquals(2, session.getProcessInstances().size());
    assertTrue(handler1.getWorkItem() != null);
    long workItemId = handler2.getWorkItem().getId();
    assertTrue(workItemId != -1);
    session = getSerialisedStatefulKnowledgeSession(session);
    session.getWorkItemManager().registerWorkItemHandler("Human Task", handler2);
    assertEquals(2, session.getProcessInstances().size());
    handler2.reset();
    session.getWorkItemManager().completeWorkItem(workItemId, null);
    assertTrue(handler2.getWorkItem() != null);
    assertEquals("John Doe", handler2.getWorkItem().getParameter("SwimlaneActorId"));
    assertEquals("x-value", handler2.getWorkItem().getParameter("Priority"));
    session.getWorkItemManager().completeWorkItem(handler1.getWorkItem().getId(), null);
    session.getWorkItemManager().completeWorkItem(handler2.getWorkItem().getId(), null);
    session.insert(new Person());
    session.fireAllRules();
    assertEquals(0, session.getProcessInstances().size());
}
Also used : TestWorkItemHandler(org.jbpm.integrationtests.handler.TestWorkItemHandler) StringReader(java.io.StringReader) KieSession(org.kie.api.runtime.KieSession) Person(org.jbpm.integrationtests.test.Person) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

StringReader (java.io.StringReader)15 TestWorkItemHandler (org.jbpm.integrationtests.handler.TestWorkItemHandler)15 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)15 Test (org.junit.Test)15 KieSession (org.kie.api.runtime.KieSession)15 ProcessInstance (org.jbpm.process.instance.ProcessInstance)10 Reader (java.io.Reader)9 HashMap (java.util.HashMap)8 WorkItem (org.kie.api.runtime.process.WorkItem)7 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)7 Person (org.jbpm.integrationtests.test.Person)6 ArrayList (java.util.ArrayList)5 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)4 ReaderResource (org.drools.core.io.impl.ReaderResource)4 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)4 KieBase (org.kie.api.KieBase)3 VariableScopeInstance (org.jbpm.process.instance.context.variable.VariableScopeInstance)2 DynamicNodeInstance (org.jbpm.workflow.instance.node.DynamicNodeInstance)2 KieRuntimeLogger (org.kie.api.logger.KieRuntimeLogger)2 DroolsError (org.drools.compiler.compiler.DroolsError)1