Java Code Examples for org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl#setClock()

The following examples show how to use org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl#setClock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleSimulationRunTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void recordEvents() {
  Clock clock = new DefaultClockImpl();
  clock.setCurrentTime(new Date(0));
  ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
  config.setClock(clock);

  ProcessEngine processEngine = (new RecordableProcessEngineFactory(config, listener))
    .getObject();

  processEngine.getRepositoryService().createDeployment().
    addClasspathResource(USERTASK_PROCESS).
    deploy();
  EventRecorderTestUtils.increaseTime(clock);

  TaskService taskService = processEngine.getTaskService();

  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put(TEST_VARIABLE, TEST_VALUE);
  processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", "oneTaskProcessBusinessKey", variables);
  EventRecorderTestUtils.increaseTime(clock);
  Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
  taskService.complete(task.getId());
  checkStatus(processEngine.getHistoryService());
  EventRecorderTestUtils.closeProcessEngine(processEngine, listener);
  ProcessEngines.destroy();
}
 
Example 2
Source File: PlaybackRunTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 3
Source File: PlaybackRunTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void recordEvents() {
  Clock clock = new DefaultClockImpl();
  ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
  config.setClock(clock);
  ProcessEngine processEngine = (new RecordableProcessEngineFactory(config, listener)).getObject();

  processEngine.getProcessEngineConfiguration().setClock(clock);
  processEngine.getRepositoryService().createDeployment().
    addClasspathResource(THE_SIMPLEST_PROCESS).
    deploy();

  Map<String,Object> variables = new HashMap<String, Object>();
  variables.put(TEST_VARIABLE, TEST_VALUE);
  processEngine.getRuntimeService().startProcessInstanceByKey(SIMPLEST_PROCESS, BUSINESS_KEY, variables);
  checkStatus(processEngine);
  EventRecorderTestUtils.closeProcessEngine(processEngine, listener);
  ProcessEngines.destroy();
}
 
Example 4
Source File: SimpleSimulationRunTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private SimulationDebugger createDebugger() {
  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);
  builder.processEngine(simulationProcessEngineFactory.getObject())
    .eventCalendar((new SimpleEventCalendarFactory(clock, new SimulationEventComparator(), listener.getSimulationEvents())).getObject())
    .eventHandlers(getHandlers());
  return builder.build();
}