use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister 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.process.instance.event.listeners.RuleAwareProcessEventLister 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");
}
use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister in project jbpm by kiegroup.
the class ActivityTest method testBusinessRuleTaskDynamic.
@Test
public void testBusinessRuleTaskDynamic() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-BusinessRuleTaskDynamic.bpmn2", "BPMN2-BusinessRuleTask.drl");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(new RuleAwareProcessEventLister());
Map<String, Object> params = new HashMap<String, Object>();
params.put("dynamicrule", "MyRuleFlow");
ProcessInstance processInstance = ksession.startProcess("BPMN2-BusinessRuleTask", params);
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister in project jbpm by kiegroup.
the class SingletonRuntimeManagerTest method testBusinessRuleTaskWithRuleAwareListener.
@Test
public void testBusinessRuleTaskWithRuleAwareListener() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.drl"), ResourceType.DRL).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
long sessionId = ksession.getIdentifier();
assertTrue(sessionId == 1);
runtime = manager.getRuntimeEngine(EmptyContext.get());
ksession = runtime.getKieSession();
assertEquals(sessionId, ksession.getIdentifier());
// start process
ksession.addEventListener(new RuleAwareProcessEventLister());
ProcessInstance pi = ksession.startProcess("BPMN2-BusinessRuleTask");
assertNull(ksession.getProcessInstance(pi.getId()));
AuditService logService = runtime.getAuditService();
List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("BPMN2-BusinessRuleTask");
assertNotNull(logs);
assertEquals(0, logs.size());
logs = logService.findProcessInstances("BPMN2-BusinessRuleTask");
assertNotNull(logs);
assertEquals(1, logs.size());
// dispose session that should not have affect on the session at all
manager.disposeRuntimeEngine(runtime);
// close manager which will close session maintained by the manager
manager.close();
}
use of org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister in project jbpm by kiegroup.
the class ErrorEventTest method testErrorBoundaryEventOnBusinessRuleTask.
@Test
public void testErrorBoundaryEventOnBusinessRuleTask() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-ErrorBoundaryEventOnBusinessRuleTask.bpmn2", "BPMN2-ErrorBoundaryEventOnBusinessRuleTask.drl");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(new RuleAwareProcessEventLister());
ProcessInstance processInstance = ksession.startProcess("BPMN2-ErrorBoundaryEventOnBusinessRuleTask");
assertProcessInstanceFinished(processInstance, ksession);
assertNodeTriggered(processInstance.getId(), "start", "business rule task error attached", "error1");
}
Aggregations