use of org.activiti.engine.impl.el.NoExecutionVariableScope in project Activiti by Activiti.
the class PlaybackRunTest method testProcessInstanceStartEvents.
@Test
public void testProcessInstanceStartEvents() throws Exception {
recordEvents();
final SimpleSimulationRun.Builder builder = new SimpleSimulationRun.Builder();
// init simulation run
Clock clock = new ThreadLocalClock(new DefaultClockFactory());
ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
config.setClock(clock);
SimulationProcessEngineFactory simulationProcessEngineFactory = new SimulationProcessEngineFactory(config);
final ProcessEngineImpl simProcessEngine = simulationProcessEngineFactory.getObject();
builder.processEngine(simProcessEngine).eventCalendar((new SimpleEventCalendarFactory(clock, new SimulationEventComparator(), listener.getSimulationEvents())).getObject()).eventHandlers(getHandlers());
SimpleSimulationRun simRun = builder.build();
simRun.execute(new NoExecutionVariableScope());
checkStatus(simProcessEngine);
simProcessEngine.getProcessEngineConfiguration().setDatabaseSchemaUpdate("create-drop");
simProcessEngine.close();
ProcessEngines.destroy();
}
use of org.activiti.engine.impl.el.NoExecutionVariableScope in project Activiti by Activiti.
the class ReplayEventLogTest method testProcessInstanceStartEvents.
@Test
public void testProcessInstanceStartEvents() throws Exception {
ProcessEngineImpl processEngine = initProcessEngine();
TaskService taskService = processEngine.getTaskService();
RuntimeService runtimeService = processEngine.getRuntimeService();
ManagementService managementService = processEngine.getManagementService();
HistoryService historyService = processEngine.getHistoryService();
// record events
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(TEST_VARIABLE, TEST_VALUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
TimeUnit.MILLISECONDS.sleep(50);
variables = new HashMap<String, Object>();
variables.put(TASK_TEST_VARIABLE, TASK_TEST_VALUE);
taskService.complete(task.getId(), variables);
// transform log events
List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(null, null);
EventLogTransformer transformer = new EventLogTransformer(getTransformers());
List<SimulationEvent> simulationEvents = transformer.transform(eventLogEntries);
SimpleEventCalendar eventCalendar = new SimpleEventCalendar(processEngine.getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
eventCalendar.addEvents(simulationEvents);
// replay process instance run
final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, eventCalendar, getReplayHandlers(processInstance.getId()));
simRun.init(new NoExecutionVariableScope());
// original process is finished - there should not be any running process instance/task
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// replay process was started
ProcessInstance replayProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).singleResult();
assertNotNull(replayProcessInstance);
assertTrue(replayProcessInstance.getId().equals(processInstance.getId()) == false);
assertEquals(TEST_VALUE, runtimeService.getVariable(replayProcessInstance.getId(), TEST_VARIABLE));
// there should be one task
assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// userTask was completed - replay process was finished
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(replayProcessInstance.getId()).variableName(TASK_TEST_VARIABLE).singleResult();
assertNotNull(variableInstance);
assertEquals(TASK_TEST_VALUE, variableInstance.getValue());
// close simulation
simRun.close();
processEngine.close();
ProcessEngines.destroy();
}
use of org.activiti.engine.impl.el.NoExecutionVariableScope in project Activiti by Activiti.
the class ReplayRunTest method testProcessInstanceStartEvents.
@Test
public void testProcessInstanceStartEvents() throws Exception {
ProcessEngineImpl processEngine = initProcessEngine();
TaskService taskService = processEngine.getTaskService();
RuntimeService runtimeService = processEngine.getRuntimeService();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put(TEST_VARIABLE, TEST_VALUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
TimeUnit.MILLISECONDS.sleep(50);
taskService.complete(task.getId());
final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, getReplayHandlers(processInstance.getId()));
simRun.init(new NoExecutionVariableScope());
// original process is finished - there should not be any running process instance/task
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// replay process was started
assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
// there should be one task
assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.step();
// userTask was completed - replay process was finished
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
simRun.close();
processEngine.close();
ProcessEngines.destroy();
}
use of org.activiti.engine.impl.el.NoExecutionVariableScope in project Activiti by Activiti.
the class SimpleSimulationRunTest method testRunToNonExistingEvent.
@Test(expected = RuntimeException.class)
public void testRunToNonExistingEvent() throws Exception {
recordEvents();
SimulationDebugger simDebugger = createDebugger();
simDebugger.init(new NoExecutionVariableScope());
try {
simDebugger.runTo("");
checkStatus(SimulationRunContext.getHistoryService());
} finally {
simDebugger.close();
ProcessEngines.destroy();
}
}
use of org.activiti.engine.impl.el.NoExecutionVariableScope in project Activiti by Activiti.
the class SimpleSimulationRunTest method testRunToTime.
@Test
public void testRunToTime() throws Exception {
recordEvents();
SimulationDebugger simDebugger = createDebugger();
simDebugger.init(new NoExecutionVariableScope());
RuntimeService runtimeService = SimulationRunContext.getRuntimeService();
TaskService taskService = SimulationRunContext.getTaskService();
HistoryService historyService = SimulationRunContext.getHistoryService();
simDebugger.runTo(0);
ProcessInstance procInstance = runtimeService.createProcessInstanceQuery().active().processInstanceBusinessKey("oneTaskProcessBusinessKey").singleResult();
assertNull(procInstance);
// debuger step - deploy process
simDebugger.runTo(1);
step0Check(SimulationRunContext.getRepositoryService());
// debuger step - start process and stay on the userTask
simDebugger.runTo(1001);
step1Check(runtimeService, taskService);
// process engine should be in the same state as before
simDebugger.runTo(2000);
step1Check(runtimeService, taskService);
// debugger step - complete userTask and finish process
simDebugger.runTo(2500);
step2Check(runtimeService, taskService);
checkStatus(historyService);
simDebugger.close();
ProcessEngines.destroy();
}
Aggregations