Search in sources :

Example 6 with Person

use of objects.Person in project jbpm by kiegroup.

the class IntermediateEventTest method testIntermediateCatchEventConditionSetVariableAfter.

@Test
public void testIntermediateCatchEventConditionSetVariableAfter() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventConditionSetVariableAfter.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent");
    assertProcessInstanceActive(processInstance);
    ksession = restoreSession(ksession, true);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    Collection<? extends Object> processInstances = ksession.getObjects(new ObjectFilter() {

        @Override
        public boolean accept(Object object) {
            if (object instanceof ProcessInstance) {
                return true;
            }
            return false;
        }
    });
    assertThat(processInstances).isNotNull();
    assertThat(processInstances.size()).isEqualTo(1);
    // now activate condition
    Person person = new Person();
    person.setName("Jack");
    ksession.insert(person);
    assertProcessInstanceFinished(processInstance, ksession);
    processInstances = ksession.getObjects(new ObjectFilter() {

        @Override
        public boolean accept(Object object) {
            if (object instanceof ProcessInstance) {
                return true;
            }
            return false;
        }
    });
    assertThat(processInstances).isNotNull();
    assertThat(processInstances.size()).isEqualTo(0);
}
Also used : KieBase(org.kie.api.KieBase) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ObjectFilter(org.kie.api.runtime.ObjectFilter) Person(org.jbpm.bpmn2.objects.Person) RuleAwareProcessEventLister(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister) Test(org.junit.Test)

Example 7 with Person

use of objects.Person in project jbpm by kiegroup.

the class IntermediateEventTest method testEventSubprocessConditional.

@Test
public void testEventSubprocessConditional() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-EventSubprocessConditional.bpmn2");
    final List<Long> executednodes = new ArrayList<Long>();
    ProcessEventListener listener = new DefaultProcessEventListener() {

        @Override
        public void afterNodeLeft(ProcessNodeLeftEvent event) {
            if (event.getNodeInstance().getNodeName().equals("Script Task 1")) {
                executednodes.add(event.getNodeInstance().getId());
            }
        }
    };
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(listener);
    TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
    ProcessInstance processInstance = ksession.startProcess("BPMN2-EventSubprocessConditional");
    assertProcessInstanceActive(processInstance);
    Person person = new Person();
    person.setName("john");
    ksession.insert(person);
    WorkItem workItem = workItemHandler.getWorkItem();
    assertThat(workItem).isNotNull();
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "start", "User Task 1", "end", "Sub Process 1", "start-sub", "Script Task 1", "end-sub");
    assertThat(executednodes.size()).isEqualTo(1);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) KieBase(org.kie.api.KieBase) NodeLeftCountDownProcessEventListener(org.jbpm.test.listener.NodeLeftCountDownProcessEventListener) ProcessEventListener(org.kie.api.event.process.ProcessEventListener) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ArrayList(java.util.ArrayList) DefaultProcessEventListener(org.kie.api.event.process.DefaultProcessEventListener) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ProcessNodeLeftEvent(org.kie.api.event.process.ProcessNodeLeftEvent) Person(org.jbpm.bpmn2.objects.Person) WorkItem(org.kie.api.runtime.process.WorkItem) Test(org.junit.Test)

Example 8 with Person

use of objects.Person in project jbpm by kiegroup.

the class IntermediateEventTest method testConditionalProcessFactInsertedBefore.

@Test
public void testConditionalProcessFactInsertedBefore() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventConditionPI.bpmn2", "BPMN2-IntermediateCatchEventSignal.bpmn2");
    ksession = createKnowledgeSession(kbase);
    Person person0 = new Person("john");
    ksession.insert(person0);
    Map<String, Object> params0 = new HashMap<String, Object>();
    params0.put("name", "john");
    ProcessInstance pi0 = ksession.startProcess("IntermediateCatchEvent", params0);
    ksession.insert(pi0);
    Person person = new Person("Jack");
    ksession.insert(person);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("name", "Poul");
    ProcessInstance pi = ksession.startProcess("IntermediateCatchEventPI", params);
    ksession.insert(pi);
    pi = ksession.getProcessInstance(pi.getId());
    assertThat(pi).isNotNull();
    Person person2 = new Person("Poul");
    ksession.insert(person2);
    pi = ksession.getProcessInstance(pi.getId());
    assertThat(pi).isNull();
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) 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 9 with Person

use of objects.Person in project jbpm by kiegroup.

the class StandaloneBPMNProcessTest method testConditionalStart.

@Test
@Ignore("bpmn does not compile")
public void testConditionalStart() throws Exception {
    KieBase kbase = createKnowledgeBase("BPMN2-ConditionalStart.bpmn2");
    KieSession ksession = createKnowledgeSession(kbase);
    Person person = new Person();
    person.setName("jack");
    ksession.insert(person);
    ksession.fireAllRules();
    person = new Person();
    person.setName("john");
    ksession.insert(person);
    ksession.fireAllRules();
}
Also used : KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) Person(org.jbpm.bpmn2.objects.Person) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with Person

use of objects.Person in project jbpm by kiegroup.

the class ErrorEventTest method testMultiErrorBoundaryEventsOnBusinessRuleTask.

@Test
public void testMultiErrorBoundaryEventsOnBusinessRuleTask() throws Exception {
    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-MultiErrorBoundaryEventsOnBusinessRuleTask.bpmn2", "BPMN2-MultiErrorBoundaryEventsOnBusinessRuleTask.drl");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("person", new Person());
    ProcessInstance processInstance = ksession.startProcess("BPMN2-MultiErrorBoundaryEventeOnBusinessRuleTask", params);
    assertProcessInstanceFinished(processInstance, ksession);
    assertNodeTriggered(processInstance.getId(), "start", "business rule task error attached", "NPE Script Task", "error1");
    ksession.dispose();
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(new RuleAwareProcessEventLister());
    params = new HashMap<String, Object>();
    params.put("person", new Person("unsupported"));
    ProcessInstance processInstance2 = ksession.startProcess("BPMN2-MultiErrorBoundaryEventeOnBusinessRuleTask", params);
    assertProcessInstanceFinished(processInstance2, ksession);
    assertNodeTriggered(processInstance2.getId(), "start", "business rule task error attached", "UOE Script Task", "error2");
}
Also used : HashMap(java.util.HashMap) KieBase(org.kie.api.KieBase) WorkflowProcessInstance(org.jbpm.workflow.instance.WorkflowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Person(org.jbpm.bpmn2.objects.Person) RuleAwareProcessEventLister(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister) 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