use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class IntermediateEventTest method testIntermediateCatchEventTimerCycleWithError.
@Test(timeout = 10000)
@RequirePersistence(false)
public void testIntermediateCatchEventTimerCycleWithError() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3);
KieBase kbase = createKnowledgeBase("BPMN2-IntermediateCatchEventTimerCycleWithError.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ksession.addEventListener(countDownListener);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", 0);
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
assertProcessInstanceActive(processInstance);
// now wait for 1 second for timer to trigger
countDownListener.waitTillCompleted();
assertProcessInstanceActive(processInstance);
processInstance = ksession.getProcessInstance(processInstance.getId());
Integer xValue = (Integer) ((WorkflowProcessInstance) processInstance).getVariable("x");
assertThat(xValue).isEqualTo(3);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class ActivityTest method testNullVariableInScriptTaskProcess.
@RequirePersistence
@Test(timeout = 10000)
public void testNullVariableInScriptTaskProcess() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1, true);
KieBase kbase = createKnowledgeBase("BPMN2-NullVariableInScriptTaskProcess.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
ProcessInstance processInstance = ksession.startProcess("nullVariableInScriptAfterTimer");
assertProcessInstanceActive(processInstance);
countDownListener.waitTillCompleted();
ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());
assertNotNull(pi);
assertProcessInstanceActive(processInstance);
ksession.abortProcessInstance(processInstance.getId());
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class ActivityTest method testRuleTaskSetVariable.
@Test
@RequirePersistence(true)
public void testRuleTaskSetVariable() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTask2.bpmn2", "BPMN2-RuleTaskSetVariable.drl");
ksession = createKnowledgeSession(kbase);
List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "SomeString");
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
ProcessInstance processInstance = ksession.startProcess("RuleTask", params);
ut.commit();
assertTrue(list.size() == 1);
assertProcessVarValue(processInstance, "x", "AnotherString");
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class ActivityTest method testCallActivityWithTimer.
@Test(timeout = 10000)
@RequirePersistence
public void testCallActivityWithTimer() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Timer", 1);
KieBase kbase = createKnowledgeBase("BPMN2-ParentProcess.bpmn2", "BPMN2-SubProcessWithTimer.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(countDownListener);
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("ParentProcess", params);
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), null);
Map<String, Object> res = new HashMap<String, Object>();
res.put("sleep", "2s");
ksession.getWorkItemManager().completeWorkItem(workItemHandler.getWorkItem().getId(), res);
long sessionId = ksession.getIdentifier();
Environment env = ksession.getEnvironment();
logger.info("dispose");
ksession.dispose();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null, env);
ksession.addEventListener(countDownListener);
countDownListener.waitTillCompleted();
assertProcessInstanceFinished(processInstance, ksession);
}
use of org.jbpm.bpmn2.test.RequirePersistence in project jbpm by kiegroup.
the class ActivityTest method testRuleTaskWithFacts.
@Test
@RequirePersistence(false)
public void testRuleTaskWithFacts() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-RuleTaskWithFact.bpmn2", "BPMN2-RuleTask3.drl");
ksession = createKnowledgeSession(kbase);
ksession.addEventListener(new AgendaEventListener() {
public void matchCreated(MatchCreatedEvent event) {
}
public void matchCancelled(MatchCancelledEvent event) {
}
public void beforeRuleFlowGroupDeactivated(org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent event) {
}
public void beforeRuleFlowGroupActivated(org.kie.api.event.rule.RuleFlowGroupActivatedEvent event) {
}
public void beforeMatchFired(BeforeMatchFiredEvent event) {
}
public void agendaGroupPushed(org.kie.api.event.rule.AgendaGroupPushedEvent event) {
}
public void agendaGroupPopped(org.kie.api.event.rule.AgendaGroupPoppedEvent event) {
}
public void afterRuleFlowGroupDeactivated(org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent event) {
}
public void afterRuleFlowGroupActivated(org.kie.api.event.rule.RuleFlowGroupActivatedEvent event) {
ksession.fireAllRules();
}
public void afterMatchFired(AfterMatchFiredEvent event) {
}
});
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "SomeString");
ProcessInstance processInstance = ksession.startProcess("RuleTask", params);
assertProcessInstanceFinished(processInstance, ksession);
params = new HashMap<String, Object>();
try {
processInstance = ksession.startProcess("RuleTask", params);
fail("Should fail");
} catch (Exception e) {
e.printStackTrace();
}
params = new HashMap<String, Object>();
params.put("x", "SomeString");
processInstance = ksession.startProcess("RuleTask", params);
assertProcessInstanceFinished(processInstance, ksession);
}
Aggregations