use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class KjarRuntimeEnvironmentTest method testScriptTaskFromClasspathContainerNamedKbaseKsession.
@Test
public void testScriptTaskFromClasspathContainerNamedKbaseKsession() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newClasspathKmoduleDefaultBuilder("defaultKieBase", "defaultKieSession").userGroupCallback(userGroupCallback).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = engine.getKieSession().startProcess("ScriptTask", params);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class MultiInstanceCallActivityRuntimeManagerTest method createEnvironment.
private RuntimeEnvironment createEnvironment() {
countDownListener = new NodeLeftCountDownProcessEventListener("timer", numberOfChildProcesses);
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("reusable-subprocess/Parent.bpmn2"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("reusable-subprocess/Child.bpmn2"), ResourceType.BPMN2).registerableItemsFactory(new DefaultRegisterableItemsFactory() {
@Override
public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
listeners.add(countDownListener);
return listeners;
}
}).get();
return environment;
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class MultiInstanceCallActivityRuntimeManagerTest method testPerProcessInstanceMultiInstanceCallactivityCompleteAtTheSameTime.
@Test(timeout = 10000)
public void testPerProcessInstanceMultiInstanceCallactivityCompleteAtTheSameTime() {
RuntimeEnvironment environment = createEnvironment();
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment, "first");
assertNotNull(manager);
testMultiInstanceCallactivityCompleteAtTheSameTime(ProcessInstanceIdContext.get());
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class PerCaseRuntimeManagerTest method testEventSignalingBetweenProcessesWithPeristence.
@Test
public void testEventSignalingBetweenProcessesWithPeristence() {
final Set<Long> ksessionUsed = new HashSet<Long>();
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2).addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2).registerableItemsFactory(new DefaultRegisterableItemsFactory() {
@Override
public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {
List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime);
listeners.add(new DefaultProcessEventListener() {
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
ksessionUsed.add(((KieSession) event.getKieRuntime()).getIdentifier());
}
});
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(CaseContext.get("Case-1"));
KieSession ksession = runtime.getKieSession();
long ksession1Id = ksession.getIdentifier();
assertNotNull(ksession);
ksession.startProcess("com.sample.bpmn.hello");
AuditService auditService = runtime.getAuditService();
List<? extends ProcessInstanceLog> throwProcessLogs = auditService.findProcessInstances("com.sample.bpmn.hello");
List<? extends ProcessInstanceLog> catchProcessLogs = auditService.findProcessInstances("com.sample.bpmn.Second");
assertNotNull(throwProcessLogs);
assertEquals(1, throwProcessLogs.size());
assertEquals(ProcessInstance.STATE_COMPLETED, throwProcessLogs.get(0).getStatus().intValue());
assertNotNull(catchProcessLogs);
assertEquals(1, catchProcessLogs.size());
assertEquals(ProcessInstance.STATE_COMPLETED, catchProcessLogs.get(0).getStatus().intValue());
assertEquals(1, ksessionUsed.size());
assertEquals(ksession1Id, ksessionUsed.iterator().next().longValue());
manager.disposeRuntimeEngine(runtime);
manager.close();
}
use of org.kie.api.runtime.manager.RuntimeEnvironment in project jbpm by kiegroup.
the class PerCaseRuntimeManagerTest method testSignalEventWithDeactivate.
@Test
public void testSignalEventWithDeactivate() {
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2).get();
manager = RuntimeManagerFactory.Factory.get().newPerCaseRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime1 = manager.getRuntimeEngine(CaseContext.get("Case-1"));
KieSession ksession1 = runtime1.getKieSession();
ksession1.signalEvent("SampleEvent", null);
List<? extends ProcessInstanceLog> logs = runtime1.getAuditService().findProcessInstances();
assertEquals(1, logs.size());
manager.disposeRuntimeEngine(runtime1);
((InternalRuntimeManager) manager).deactivate();
runtime1 = manager.getRuntimeEngine(CaseContext.get("Case-1"));
ksession1 = runtime1.getKieSession();
ksession1.signalEvent("SampleEvent", null);
logs = runtime1.getAuditService().findProcessInstances();
assertEquals(1, logs.size());
manager.disposeRuntimeEngine(runtime1);
((InternalRuntimeManager) manager).activate();
runtime1 = manager.getRuntimeEngine(CaseContext.get("Case-1"));
ksession1 = runtime1.getKieSession();
ksession1.signalEvent("SampleEvent", null);
logs = runtime1.getAuditService().findProcessInstances();
assertEquals(2, logs.size());
manager.disposeRuntimeEngine(runtime1);
}
Aggregations