Java Code Examples for org.camunda.bpm.engine.impl.util.ClockUtil#reset()

The following examples show how to use org.camunda.bpm.engine.impl.util.ClockUtil#reset() . 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: HistoricTaskInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskReturnedBeforeEndTime() {
  // given
  Task taskOne = taskService.newTask("taskOne");

  // when
  taskOne.setAssignee("aUserId");
  taskService.saveTask(taskOne);

  Calendar hourAgo = Calendar.getInstance();
  hourAgo.add(Calendar.HOUR_OF_DAY, -1);
  ClockUtil.setCurrentTime(hourAgo.getTime());

  taskService.complete(taskOne.getId());

  List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
          .finishedBefore(hourAgo.getTime()).list();

  // then
  assertEquals(1, list.size());

  // cleanup
  taskService.deleteTask("taskOne",true);
  ClockUtil.reset();
}
 
Example 2
Source File: ExternalTaskLockExpTimeScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("initExternalTaskLockExpTime")
@Times(1)
public static ScenarioSetup initExternalTaskLockExpTime() {
  return new ScenarioSetup() {
    @Override
    public void execute(ProcessEngine processEngine, String scenarioName) {

      ClockUtil.setCurrentTime(TIMESTAMP);

      deployModel(processEngine, PROCESS_DEFINITION_KEY, PROCESS_DEFINITION_KEY, EXT_TASK_MODEL);

      processEngine.getRuntimeService()
        .startProcessInstanceByKey(PROCESS_DEFINITION_KEY, scenarioName);

      processEngine.getExternalTaskService()
        .fetchAndLock(1, WORKER_ID)
        .topic(TOPIC_NAME, LOCK_TIME)
        .execute();

      ClockUtil.reset();
    }
  };
}
 
Example 3
Source File: IncidentTimestampScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("initIncidentTimestamp")
@Times(1)
public static ScenarioSetup initIncidentTimestamp() {
  return new ScenarioSetup() {
    @Override
    public void execute(ProcessEngine processEngine, String scenarioName) {

      ClockUtil.setCurrentTime(TIMESTAMP);

      deployModel(processEngine, PROCESS_DEFINITION_KEY, PROCESS_DEFINITION_KEY, FAILING_SERVICE_TASK_MODEL);

      String processInstanceId = processEngine.getRuntimeService()
        .startProcessInstanceByKey(PROCESS_DEFINITION_KEY, scenarioName)
        .getId();

      causeIncident(processEngine, processInstanceId);

      ClockUtil.reset();
    }
  };
}
 
Example 4
Source File: AbstractHistoryCleanupSchedulerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void tearDownAfterAll() {
  if (engineConfiguration != null) {
    engineConfiguration
      .setHistoryRemovalTimeProvider(null)
      .setHistoryRemovalTimeStrategy(null)
      .initHistoryRemovalTime();

    engineConfiguration.setHistoryCleanupStrategy(HISTORY_CLEANUP_STRATEGY_END_TIME_BASED);

    engineConfiguration.setHistoryCleanupBatchSize(MAX_BATCH_SIZE);
    engineConfiguration.setHistoryCleanupBatchWindowStartTime(null);
    engineConfiguration.setHistoryCleanupDegreeOfParallelism(1);

    engineConfiguration.initHistoryCleanup();
  }

  ClockUtil.reset();
}
 
Example 5
Source File: HistoricDecisionInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN })
public void testQueryByEvaluatedAfter() {
  Date beforeEvaluated = new Date(1441612000);
  Date evaluated = new Date(1441613000);
  Date afterEvaluated = new Date(1441614000);

  ClockUtil.setCurrentTime(evaluated);
  startProcessInstanceAndEvaluateDecision();

  HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
  assertThat(query.evaluatedAfter(beforeEvaluated).count(), is(1L));
  assertThat(query.evaluatedAfter(evaluated).count(), is(1L));
  assertThat(query.evaluatedAfter(afterEvaluated).count(), is(0L));

  ClockUtil.reset();
}
 
Example 6
Source File: HistoryCleanupRemovalTimeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@AfterClass
public static void tearDownAfterAll() {
  if (engineConfiguration != null) {
    engineConfiguration
      .setHistoryRemovalTimeProvider(null)
      .setHistoryRemovalTimeStrategy(null)
      .initHistoryRemovalTime();

    engineConfiguration.setHistoryCleanupStrategy(HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED);

    engineConfiguration.setHistoryCleanupBatchSize(MAX_BATCH_SIZE);
    engineConfiguration.setHistoryCleanupBatchWindowStartTime(null);
    engineConfiguration.setHistoryCleanupDegreeOfParallelism(1);

    engineConfiguration.setBatchOperationHistoryTimeToLive(null);
    engineConfiguration.setBatchOperationsForHistoryCleanup(null);

    engineConfiguration.initHistoryCleanup();

    engineConfiguration.setAuthorizationEnabled(false);
    engineConfiguration.setEnableHistoricInstancePermissions(false);
  }

  ClockUtil.reset();
}
 
Example 7
Source File: BatchSetRemovalTimeRule.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void finished(Description description) {
  getProcessEngineConfiguration()
    .setHistoryRemovalTimeProvider(null)
    .setHistoryRemovalTimeStrategy(null)
    .initHistoryRemovalTime();

  getProcessEngineConfiguration().setBatchOperationHistoryTimeToLive(null);
  getProcessEngineConfiguration().setBatchOperationsForHistoryCleanup(null);

  getProcessEngineConfiguration().setBatchOperationHistoryTimeToLive(null);
  getProcessEngineConfiguration().setHistoryCleanupStrategy(null);
  getProcessEngineConfiguration().initHistoryCleanup();

  getProcessEngineConfiguration().setInvocationsPerBatchJob(1);

  getProcessEngineConfiguration().setDmnEnabled(true);

  DefaultDmnEngineConfiguration dmnEngineConfiguration =
      getProcessEngineConfiguration().getDmnEngineConfiguration();

  ResetDmnConfigUtil.reset(dmnEngineConfiguration)
      .enableFeelLegacyBehavior(false)
      .init();

  ClockUtil.reset();

  clearDatabase();

  getProcessEngineConfiguration().setEnableHistoricInstancePermissions(false);
  getProcessEngineConfiguration().setAuthorizationEnabled(false);

  super.finished(description);
}
 
Example 8
Source File: CleanableHistoricBatchReportTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void cleanUp() {
  ClockUtil.reset();
  migrationHelper.removeAllRunningAndHistoricBatches();
  processEngineConfiguration.setBatchOperationHistoryTimeToLive(null);
  processEngineConfiguration.setBatchOperationsForHistoryCleanup(null);
}
 
Example 9
Source File: GetCompletedHistoricActivityInstancesForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void resultIsSortedByEndTime() {
   // given
  BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process")
    .startEvent("startEvent")
    .serviceTask("ServiceTask1")
      .camundaExpression("${true}")
      .camundaExecutionListenerClass(EVENTNAME_START, ShiftTimeByOneMinuteListener.class.getName())
    .serviceTask("ServiceTask2")
      .camundaExpression("${true}")
      .camundaExecutionListenerClass(EVENTNAME_START, ShiftTimeByOneMinuteListener.class.getName())
    .serviceTask("ServiceTask3")
      .camundaExpression("${true}")
      .camundaExecutionListenerClass(EVENTNAME_START, ShiftTimeByOneMinuteListener.class.getName())
    .endEvent("endEvent")
      .camundaExecutionListenerClass(EVENTNAME_START, ShiftTimeByOneMinuteListener.class.getName())
    .done();
  testHelper.deploy(simpleDefinition);
  ClockUtil.setCurrentTime(new Date());
  engineRule.getRuntimeService().startProcessInstanceByKey("process");
  ClockUtil.reset();

  // when
  List<HistoricActivityInstance> completedHistoricActivityInstances =
    optimizeService.getCompletedHistoricActivityInstances(pastDate(), null, 4);

  // then
  assertThat(completedHistoricActivityInstances.size(), is(4));
  assertThat(completedHistoricActivityInstances.get(0).getActivityId(), is("startEvent"));
  assertThat(completedHistoricActivityInstances.get(1).getActivityId(), is("ServiceTask1"));
  assertThat(completedHistoricActivityInstances.get(2).getActivityId(), is("ServiceTask2"));
  assertThat(completedHistoricActivityInstances.get(3).getActivityId(), is("ServiceTask3"));
}
 
Example 10
Source File: HistoricTaskInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskNotReturnedAfterEndTime() {
  // given
  Task taskOne = taskService.newTask("taskOne");

  // when
  taskOne.setAssignee("aUserId");
  taskService.saveTask(taskOne);

  Calendar hourAgo = Calendar.getInstance();
  hourAgo.add(Calendar.HOUR_OF_DAY, -1);
  ClockUtil.setCurrentTime(hourAgo.getTime());

  taskService.complete(taskOne.getId());

  List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
          .finishedAfter(Calendar.getInstance().getTime()).list();

  // then
  assertEquals(0, list.size());

  // cleanup
  taskService.deleteTask("taskOne",true);

  ClockUtil.reset();
}
 
Example 11
Source File: GetCompletedHistoricTaskInstancesForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void cleanUp() {
  for (User user : identityService.createUserQuery().list()) {
    identityService.deleteUser(user.getId());
  }
  for (Group group : identityService.createGroupQuery().list()) {
    identityService.deleteGroup(group.getId());
  }
  for (Authorization authorization : authorizationService.createAuthorizationQuery().list()) {
    authorizationService.deleteAuthorization(authorization.getId());
  }
  ClockUtil.reset();
}
 
Example 12
Source File: GetCompletedHistoricProcessInstancesForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@After
public void cleanUp() {
  for (User user : identityService.createUserQuery().list()) {
    identityService.deleteUser(user.getId());
  }
  for (Group group : identityService.createGroupQuery().list()) {
    identityService.deleteGroup(group.getId());
  }
  for (Authorization authorization : authorizationService.createAuthorizationQuery().list()) {
    authorizationService.deleteAuthorization(authorization.getId());
  }
  ClockUtil.reset();
}
 
Example 13
Source File: ProcessDataLoggingContextTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void resetClock() {
  ClockUtil.reset();
}
 
Example 14
Source File: ExternalTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void tearDown() throws Exception {
  ClockUtil.reset();
}
 
Example 15
Source File: DurationHelperTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void tearDown() {
  ClockUtil.reset();
}
 
Example 16
Source File: ModificationUserOperationLogTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void resetClock() {
  ClockUtil.reset();
}
 
Example 17
Source File: TimerChangeProcessDefinitionTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void resetClock() {
  ClockUtil.reset();
}
 
Example 18
Source File: AbstractJobExecutorAcquireJobsTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void resetClock() {
  ClockUtil.reset();
}
 
Example 19
Source File: HistoryCleanupTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@After
public void resetClock() {
  ClockUtil.reset();
}
 
Example 20
Source File: HistoricTaskReportTest.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
protected void startAndCompleteProcessInstance(String key, int year, int month, int dayOfMonth, int hourOfDay, int minute) {
  setCurrentTime(year, month, dayOfMonth , hourOfDay, minute);

  ProcessInstance pi = processEngineRule.getRuntimeService().startProcessInstanceByKey(key);

  addToCalendar(Calendar.MONTH, 5);
  completeTask(pi.getId());

  ClockUtil.reset();
}