use of org.kie.api.event.process.ProcessCompletedEvent in project jbpm by kiegroup.
the class PerProcessInstanceRuntimeManagerTest method testEventSignalingBetweenProcesses.
@Test
public void testEventSignalingBetweenProcesses() {
final Map<String, Integer> processStates = new HashMap<String, Integer>();
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder().persistence(false).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 = new ArrayList<ProcessEventListener>();
listeners.add(new DefaultProcessEventListener() {
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
});
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ksession.startProcess("com.sample.bpmn.hello");
assertEquals(2, processStates.size());
assertTrue(processStates.containsKey("com.sample.bpmn.hello"));
assertTrue(processStates.containsKey("com.sample.bpmn.Second"));
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.hello").intValue());
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.Second").intValue());
manager.disposeRuntimeEngine(runtime);
manager.close();
}
use of org.kie.api.event.process.ProcessCompletedEvent in project jbpm by kiegroup.
the class PerRequestRuntimeManagerTest method testEventSignalingBetweenProcesses.
@Test
public void testEventSignalingBetweenProcesses() {
final Map<String, Integer> processStates = new HashMap<String, Integer>();
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder().persistence(false).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 = new ArrayList<ProcessEventListener>();
listeners.add(new DefaultProcessEventListener() {
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
});
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ksession.startProcess("com.sample.bpmn.hello");
assertEquals(2, processStates.size());
assertTrue(processStates.containsKey("com.sample.bpmn.hello"));
assertTrue(processStates.containsKey("com.sample.bpmn.Second"));
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.hello").intValue());
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.Second").intValue());
manager.disposeRuntimeEngine(runtime);
manager.close();
}
use of org.kie.api.event.process.ProcessCompletedEvent in project jbpm by kiegroup.
the class SingletonRuntimeManagerTest method testEventSignalingBetweenProcesses.
@Test
public void testEventSignalingBetweenProcesses() {
final Map<String, Integer> processStates = new HashMap<String, Integer>();
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder().persistence(false).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 = new ArrayList<ProcessEventListener>();
listeners.add(new DefaultProcessEventListener() {
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
}
});
return listeners;
}
}).get();
manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
assertNotNull(manager);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
assertNotNull(ksession);
ksession.startProcess("com.sample.bpmn.hello");
assertEquals(2, processStates.size());
assertTrue(processStates.containsKey("com.sample.bpmn.hello"));
assertTrue(processStates.containsKey("com.sample.bpmn.Second"));
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.hello").intValue());
assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.Second").intValue());
manager.disposeRuntimeEngine(runtime);
manager.close();
}
Aggregations