use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createHistoricTaskInstanceMock.
private void createHistoricTaskInstanceMock() {
List<HistoricTaskInstance> tasks = MockProvider.createMockHistoricTaskInstances();
HistoricTaskInstanceQuery query = mock(HistoricTaskInstanceQuery.class);
when(mockHistoryService.createHistoricTaskInstanceQuery()).thenReturn(query);
when(query.list()).thenReturn(tasks);
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class MockProvider method createMockHistoricTaskInstance.
public static HistoricTaskInstance createMockHistoricTaskInstance(String tenantId) {
HistoricTaskInstance taskInstance = mock(HistoricTaskInstance.class);
when(taskInstance.getId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_ID);
when(taskInstance.getProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_PROC_INST_ID);
when(taskInstance.getActivityInstanceId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_ACT_INST_ID);
when(taskInstance.getExecutionId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_EXEC_ID);
when(taskInstance.getProcessDefinitionId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_PROC_DEF_ID);
when(taskInstance.getProcessDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_PROC_DEF_KEY);
when(taskInstance.getName()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_NAME);
when(taskInstance.getDescription()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DESCRIPTION);
when(taskInstance.getDeleteReason()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DELETE_REASON);
when(taskInstance.getOwner()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_OWNER);
when(taskInstance.getAssignee()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_ASSIGNEE);
when(taskInstance.getStartTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_TASK_INST_START_TIME));
when(taskInstance.getEndTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_TASK_INST_END_TIME));
when(taskInstance.getDurationInMillis()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DURATION);
when(taskInstance.getTaskDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_DEF_KEY);
when(taskInstance.getPriority()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_PRIORITY);
when(taskInstance.getDueDate()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_TASK_INST_DUE_DATE));
when(taskInstance.getFollowUpDate()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_TASK_INST_FOLLOW_UP_DATE));
when(taskInstance.getParentTaskId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_PARENT_TASK_ID);
when(taskInstance.getCaseDefinitionKey()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_CASE_DEF_KEY);
when(taskInstance.getCaseDefinitionId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_CASE_DEF_ID);
when(taskInstance.getCaseInstanceId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_CASE_INST_ID);
when(taskInstance.getCaseExecutionId()).thenReturn(EXAMPLE_HISTORIC_TASK_INST_CASE_EXEC_ID);
when(taskInstance.getTenantId()).thenReturn(tenantId);
return taskInstance;
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceRestServiceImpl method queryHistoricTaskInstances.
@Override
public List<HistoricTaskInstanceDto> queryHistoricTaskInstances(HistoricTaskInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
queryDto.setObjectMapper(objectMapper);
HistoricTaskInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricTaskInstance> match;
if (firstResult != null || maxResults != null) {
match = executePaginatedQuery(query, firstResult, maxResults);
} else {
match = query.list();
}
List<HistoricTaskInstanceDto> result = new ArrayList<HistoricTaskInstanceDto>();
for (HistoricTaskInstance taskInstance : match) {
HistoricTaskInstanceDto taskInstanceDto = HistoricTaskInstanceDto.fromHistoricTaskInstance(taskInstance);
result.add(taskInstanceDto);
}
return result;
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class MigrationHistoricTaskInstanceTest method testMigrateHistoryUserTaskInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoryUserTaskInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2"));
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
HistoricTaskInstanceQuery sourceHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
HistoricTaskInstanceQuery targetHistoryTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstance.getId());
// when
assertEquals(1, sourceHistoryTaskInstanceQuery.count());
assertEquals(0, targetHistoryTaskInstanceQuery.count());
ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();
// then
assertEquals(0, sourceHistoryTaskInstanceQuery.count());
assertEquals(1, targetHistoryTaskInstanceQuery.count());
HistoricTaskInstance instance = targetHistoryTaskInstanceQuery.singleResult();
assertEquals(targetProcessDefinition.getKey(), instance.getProcessDefinitionKey());
assertEquals(targetProcessDefinition.getId(), instance.getProcessDefinitionId());
assertEquals("userTask2", instance.getTaskDefinitionKey());
assertEquals(activityInstance.getActivityInstances("userTask")[0].getId(), instance.getActivityInstanceId());
}
use of org.camunda.bpm.engine.history.HistoricTaskInstance in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskNotReturnedAfterEndTime.
@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();
}
Aggregations