use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedJobWithEmptyInterval.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstExecutedJobWithEmptyInterval() {
// 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 proc inst with executed job before and after an hour before the starting time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobBefore(hourBeforeNow.getTime()).executedJobAfter(hourBeforeNow.getTime()).singleResult();
// then query returns no result
assertNull(historicProcessInstance);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstQueryWithActiveActivityIds.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstQueryWithActiveActivityIds() {
// given
deployment(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
// assume
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("userTask1").singleResult();
assertNotNull(historicActivityInstance);
// when
List<HistoricProcessInstance> result = historyService.createHistoricProcessInstanceQuery().activeActivityIdIn(historicActivityInstance.getActivityId()).list();
// then
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(result.get(0).getId(), processInstance.getId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedJobWithTwoProcInsts.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstExecutedJobWithTwoProcInsts() {
// 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);
ClockUtil.setCurrentTime(hourBeforeNow.getTime());
runtimeService.startProcessInstanceByKey("async");
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
ClockUtil.setCurrentTime(now.getTime());
runtimeService.startProcessInstanceByKey("async");
runtimeService.startProcessInstanceByKey("proc");
// when query executed job between now and an hour ago
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().executedJobAfter(hourBeforeNow.getTime()).executedJobBefore(now.getTime()).list();
// then the two async historic process instance have to be returned
assertEquals(2, list.size());
// when query execute activity after an half hour before now
Calendar halfHour = (Calendar) now.clone();
halfHour.add(Calendar.MINUTE, -30);
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobAfter(halfHour.getTime()).singleResult();
// then only the latest async historic process instance is returned
assertNotNull(historicProcessInstance);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstExecutedJobAfter.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstExecutedJobAfter() {
// 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 hourFromNow = (Calendar) now.clone();
hourFromNow.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 after the start time
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobAfter(now.getTime()).singleResult();
// then query returns only a single process instance
assertNotNull(historicProcessInstance);
// when query historic proc inst with execute job after a hour of the starting time
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().executedJobAfter(hourFromNow.getTime()).singleResult();
// then query returns no result
assertNull(historicProcessInstance);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskWasUnassigned.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasUnassigned() {
// given
Task taskOne = taskService.newTask("taskOne");
Task taskTwo = taskService.newTask("taskTwo");
Task taskThree = taskService.newTask("taskThree");
// when
taskOne.setAssignee("aUserId");
taskService.saveTask(taskOne);
taskTwo.setAssignee("anotherUserId");
taskService.saveTask(taskTwo);
taskService.saveTask(taskThree);
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskUnassigned().list();
// then
assertEquals(list.size(), 1);
// cleanup
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
Aggregations