use of org.kie.api.executor.CommandContext in project jbpm by kiegroup.
the class BasicExecutorIntegrationTest method callbackTest.
@Test
public void callbackTest() throws InterruptedException {
CommandContext commandContext = new CommandContext();
commandContext.setData("businessKey", UUID.randomUUID().toString());
cachedEntities.put((String) commandContext.getData("businessKey"), new AtomicLong(1));
commandContext.setData("callbacks", "org.jbpm.executor.ejb.impl.test.SimpleIncrementCallback");
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", commandContext);
Thread.sleep(10000);
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(1, executedRequests.size());
assertEquals(2, ((AtomicLong) cachedEntities.get((String) commandContext.getData("businessKey"))).longValue());
}
use of org.kie.api.executor.CommandContext in project jbpm by kiegroup.
the class AsyncIntermediateCatchSignalTest method testCorrectProcessStateAfterExceptionSignalCommandMulti.
@Test(timeout = 20000)
public void testCorrectProcessStateAfterExceptionSignalCommandMulti() throws InterruptedException {
latch = new CountDownLatch(5);
RuntimeManager runtimeManager = createRuntimeManager(BPMN_AICS);
KieSession ksession = getRuntimeEngine().getKieSession();
long[] pid = new long[5];
for (int i = 0; i < 5; i++) {
ProcessInstance pi = ksession.startProcess(PROCESS_AICS, null);
pid[i] = pi.getId();
CommandContext ctx = new CommandContext();
ctx.setData("DeploymentId", runtimeManager.getIdentifier());
ctx.setData("ProcessInstanceId", pi.getId());
ctx.setData("Signal", "MySignal");
ctx.setData("Event", null);
executorService.scheduleRequest(AsyncSignalEventCommand.class.getName(), ctx);
}
latch.await();
for (long p : pid) {
ProcessInstance pi = ksession.getProcessInstance(p);
Assertions.assertThat(pi).isNull();
}
}
Aggregations