use of org.jbpm.bpmn2.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);
}
use of org.jbpm.bpmn2.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);
}
use of org.jbpm.bpmn2.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();
}
use of org.jbpm.bpmn2.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();
}
use of org.jbpm.bpmn2.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");
}
Aggregations