use of org.camunda.bpm.engine.test.RequiredHistoryLevel 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();
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskInvolvedUser.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskInvolvedUser() {
// given
runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId("aAssignerId");
taskService.addCandidateUser(taskId, "aUserId");
taskService.addCandidateUser(taskId, "bUserId");
taskService.deleteCandidateUser(taskId, "aUserId");
taskService.deleteCandidateUser(taskId, "bUserId");
Task taskAssignee = taskService.newTask("newTask");
taskAssignee.setAssignee("aUserId");
taskService.saveTask(taskAssignee);
// query test
assertEquals(2, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("aUserId").count());
assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("bUserId").count());
assertEquals(0, historyService.createHistoricTaskInstanceQuery().taskInvolvedUser("invalidUserId").count());
taskService.deleteTask("newTask", true);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskWasAssigned.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testTaskWasAssigned() {
// 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().taskAssigned().list();
// then
assertEquals(list.size(), 2);
// cleanup
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testTaskReturnedBeforeEndTime.
@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();
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testStandaloneTaskRemoveVariableLocalWithReadPermissionOnAnyTask.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testStandaloneTaskRemoveVariableLocalWithReadPermissionOnAnyTask() {
// given
String taskId = "myTask";
createTask(taskId);
createGrantAuthorization(TASK, ANY, userId, UPDATE);
disableAuthorization();
taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);
enableAuthorization();
// when
taskService.removeVariableLocal(taskId, VARIABLE_NAME);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
verifyQueryResults(query, 0);
enableAuthorization();
deleteTask(taskId, true);
HistoricVariableInstance deletedVariable = historyService.createHistoricVariableInstanceQuery().includeDeleted().singleResult();
Assert.assertEquals("DELETED", deletedVariable.getState());
}
Aggregations