Search in sources :

Example 36 with Person

use of objects.Person in project jbpm by kiegroup.

the class ActivityTest method testBusinessRuleTaskFireLimit.

@Test
public void testBusinessRuleTaskFireLimit() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTaskLoop.bpmn2", "BPMN2-BusinessRuleTaskInfiniteLoop.drl");
    ksession = createKnowledgeSession(kbase);
    ksession.insert(new Person());
    assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> {
        ksession.startProcess("BPMN2-BusinessRuleTask");
    }).withMessageContaining("Fire rule limit reached 10000");
}
Also used : KieBase(org.kie.api.KieBase) Person(org.jbpm.bpmn2.objects.Person) Test(org.junit.Test)

Example 37 with Person

use of objects.Person in project jbpm by kiegroup.

the class ActivityTest method testScriptTaskJS.

@Test
public void testScriptTaskJS() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-ScriptTaskJS.bpmn2");
    ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("name", "krisv");
    Person person = new Person();
    person.setName("krisv");
    params.put("person", person);
    WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("ScriptTask", params);
    assertEquals("Entry", processInstance.getVariable("x"));
    assertNull(processInstance.getVariable("y"));
    ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null);
    assertEquals("Exit", getProcessVarValue(processInstance, "y"));
    assertEquals("tester", processInstance.getVariable("surname"));
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) Person(org.jbpm.bpmn2.objects.Person) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Test(org.junit.Test)

Example 38 with Person

use of objects.Person in project jbpm by kiegroup.

the class ActivityTest method testAdHocProcessDynamicSubProcess.

@Test
public void testAdHocProcessDynamicSubProcess() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-AdHocProcess.bpmn2", "BPMN2-MinimalProcess.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ProcessInstance processInstance = ksession.startProcess("AdHocProcess");
    assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession, true);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    logger.debug("Triggering node");
    ksession.signalEvent("Task1", null, processInstance.getId());
    assertProcessInstanceActive(processInstance);
    TestWorkItemHandler workItemHandler2 = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("OtherTask", workItemHandler2);
    DynamicUtils.addDynamicSubProcess(processInstance, ksession, "Minimal", new HashMap<String, Object>());
    ksession = restoreSession(ksession, true);
    ksession.signalEvent("User1", null, processInstance.getId());
    assertProcessInstanceActive(processInstance);
    ksession.insert(new Person());
    ksession.signalEvent("Task3", null, processInstance.getId());
    assertProcessInstanceFinished(processInstance, ksession);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Person(org.jbpm.bpmn2.objects.Person) Test(org.junit.Test)

Example 39 with Person

use of objects.Person in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testIntermediateCatchEventCondition.

@Test
@Ignore("process does not complete")
public void testIntermediateCatchEventCondition() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventCondition.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertThat(processInstance.getState()).isEqualTo(ProcessInstance.STATE_ACTIVE);
    ksession = restoreSession(ksession);
    // now activate condition
    Person person = new Person();
    person.setName("Jack");
    ksession.insert(person);
    assertProcessInstanceCompleted(processInstance.getId(), ksession);
}
Also used : KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) Person(org.jbpm.bpmn2.objects.Person) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 40 with Person

use of objects.Person in project jbpm by kiegroup.

the class BusinessRuleTaskHandlerTest method testDrlStatelessBusinessRuleTaskNoScanner.

@Test
public void testDrlStatelessBusinessRuleTaskNoScanner() {
    TestWorkItemManager manager = new TestWorkItemManager();
    BusinessRuleTaskHandler handler = new BusinessRuleTaskHandler(GROUP_ID, ARTIFACT_ID, VERSION);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setId(999);
    Person person = new Person("john");
    workItem.setParameter("person", person);
    handler.executeWorkItem(workItem, manager);
    Map<String, Object> results = manager.getResults(workItem.getId());
    assertNotNull(results);
    assertEquals(1, results.size());
    assertEquals(35, ((Person) results.get("person")).getAge().intValue());
}
Also used : TestWorkItemManager(org.jbpm.process.workitem.core.TestWorkItemManager) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) Person(org.jbpm.process.workitem.bpmn2.objects.Person) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)32 Person (org.jbpm.bpmn2.objects.Person)29 KieBase (org.kie.api.KieBase)28 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)22 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 HashMap (java.util.HashMap)10 Person (objects.Person)8 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)8 ArrayList (java.util.ArrayList)6 Tile (objects.Tile)4 Ignore (org.junit.Ignore)4 KieSession (org.kie.api.runtime.KieSession)4 BaseMap (objects.BaseMap)3 DoNothingWorkItemHandler (org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 Region (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)2 TiledMapTileLayer (com.badlogic.gdx.maps.tiled.TiledMapTileLayer)2 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)2