use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricActivityInstanceTest method testMigrateHistoricActivityInstanceAddScope.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoricActivityInstanceAddScope() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapActivities("userTask", "userTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
// when
rule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).unfinished().orderByActivityId().asc().list();
Assert.assertEquals(2, historicInstances.size());
assertMigratedTo(historicInstances.get(0), targetDefinition, "subProcess");
assertMigratedTo(historicInstances.get(1), targetDefinition, "userTask");
assertEquals(processInstance.getId(), historicInstances.get(0).getParentActivityInstanceId());
assertEquals(historicInstances.get(0).getId(), historicInstances.get(1).getParentActivityInstanceId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method noHistoryUpdateOnAddScopeMigration.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void noHistoryUpdateOnAddScopeMigration() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0).getParent();
runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", 42);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then there is still one historic variable instance
Assert.assertEquals(1, historyService.createHistoricVariableInstanceQuery().count());
// and no additional historic details
Assert.assertEquals(1, historyService.createHistoricDetailQuery().count());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method testMigrateEventScopeVariable.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testMigrateEventScopeVariable() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("subProcess", "subProcess").mapActivities("compensationBoundary", "compensationBoundary").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId());
Execution subProcessExecution = runtimeService.createExecutionQuery().activityId("userTask1").singleResult();
runtimeService.setVariableLocal(subProcessExecution.getId(), "foo", "bar");
testHelper.completeTask("userTask1");
Execution eventScopeExecution = runtimeService.createExecutionQuery().activityId("subProcess").singleResult();
HistoricVariableInstance eventScopeVariable = historyService.createHistoricVariableInstanceQuery().executionIdIn(eventScopeExecution.getId()).singleResult();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableId(eventScopeVariable.getId()).singleResult();
Assert.assertEquals(targetDefinition.getId(), historicVariableInstance.getProcessDefinitionId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel 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.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricTaskInstanceQueryTest method testGroupTaskQuery.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testGroupTaskQuery() {
// given
runtimeService.startProcessInstanceByKey("oneTaskProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId("aAssignerId");
taskService.addCandidateUser(taskId, "aUserId");
taskService.addCandidateGroup(taskId, "aGroupId");
taskService.addCandidateGroup(taskId, "bGroupId");
Task taskOne = taskService.newTask("taskOne");
taskOne.setAssignee("aUserId");
taskService.saveTask(taskOne);
Task taskTwo = taskService.newTask("taskTwo");
taskTwo.setAssignee("aUserId");
taskService.saveTask(taskTwo);
Task taskThree = taskService.newTask("taskThree");
taskThree.setOwner("aUserId");
taskService.saveTask(taskThree);
taskService.deleteCandidateGroup(taskId, "aGroupId");
taskService.deleteCandidateGroup(taskId, "bGroupId");
historyService.createHistoricTaskInstanceQuery();
// Query test
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
assertEquals(4, query.taskInvolvedUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(1, query.taskHadCandidateUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(1, query.taskHadCandidateGroup("aGroupId").count());
assertEquals(1, query.taskHadCandidateGroup("bGroupId").count());
assertEquals(0, query.taskInvolvedUser("aUserId").count());
query = historyService.createHistoricTaskInstanceQuery();
assertEquals(4, query.taskInvolvedUser("aUserId").count());
assertEquals(1, query.taskHadCandidateUser("aUserId").count());
assertEquals(1, query.taskInvolvedUser("aUserId").count());
// delete task
taskService.deleteTask("taskOne", true);
taskService.deleteTask("taskTwo", true);
taskService.deleteTask("taskThree", true);
}
Aggregations