Search in sources :

Example 76 with RequiredHistoryLevel

use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.

the class HistoricProcessInstanceTest method testHistoricProcInstExecutedJobBefore.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstExecutedJobBefore() {
    // given
    BpmnModelInstance asyncModel = Bpmn.createExecutableProcess("async").startEvent().camundaAsyncBefore().endEvent().done();
    deployment(asyncModel);
    BpmnModelInstance model = Bpmn.createExecutableProcess("proc").startEvent().endEvent().done();
    deployment(model);
    Calendar now = Calendar.getInstance();
    ClockUtil.setCurrentTime(now.getTime());
    Calendar hourBeforeNow = (Calendar) now.clone();
    hourBeforeNow.add(Calendar.HOUR_OF_DAY, -1);
    runtimeService.startProcessInstanceByKey("async");
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    runtimeService.startProcessInstanceByKey("proc");
    // when query historic process instance which has executed an job before the start time
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobBefore(now.getTime()).singleResult();
    // then query returns only a single process instance since before is less-then-equal
    assertNotNull(historicProcessInstance);
    // when query historic proc inst with executed job before an hour of the starting time
    historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobBefore(hourBeforeNow.getTime()).singleResult();
    // then query returns no result
    assertNull(historicProcessInstance);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)76 Test (org.junit.Test)47 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)43 Deployment (org.camunda.bpm.engine.test.Deployment)24 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)17 Batch (org.camunda.bpm.engine.batch.Batch)13 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)13 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)12 Task (org.camunda.bpm.engine.task.Task)12 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)12 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)11 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)10 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Calendar (java.util.Calendar)6 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)6 Job (org.camunda.bpm.engine.runtime.Job)6 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)6 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 GregorianCalendar (java.util.GregorianCalendar)4