use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricActivityInstanceTest method testMigrateHistoricSubProcessInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoricSubProcessInstance() {
// given
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(ProcessModels.SCOPE_TASK_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(processDefinition.getId(), processDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(processDefinition.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), processDefinition, "subProcess");
assertMigratedTo(historicInstances.get(1), processDefinition, "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 MigrationHistoricActivityInstanceTest method testMigrateHistoryActivityInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoryActivityInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId("Process", "Process2").changeElementId("userTask", "userTask2").changeElementName("userTask", "new activity name"));
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
HistoricActivityInstanceQuery sourceHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
HistoricActivityInstanceQuery targetHistoryActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
// when
assertEquals(2, sourceHistoryActivityInstanceQuery.count());
assertEquals(0, targetHistoryActivityInstanceQuery.count());
ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();
// then one instance of the start event still belongs to the source process
// and one active user task instances is now migrated to the target process
assertEquals(1, sourceHistoryActivityInstanceQuery.count());
assertEquals(1, targetHistoryActivityInstanceQuery.count());
HistoricActivityInstance instance = targetHistoryActivityInstanceQuery.singleResult();
assertMigratedTo(instance, targetProcessDefinition, "userTask2");
assertEquals("new activity name", instance.getActivityName());
assertEquals(processInstance.getId(), instance.getParentActivityInstanceId());
assertEquals("userTask", instance.getActivityType());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricProcessInstanceTest method testMigrateHistoryProcessInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoryProcessInstance() {
// given
HistoricProcessInstanceQuery sourceHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
HistoricProcessInstanceQuery targetHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(targetProcessDefinition.getId());
// when
assertEquals(1, sourceHistoryProcessInstanceQuery.count());
assertEquals(0, targetHistoryProcessInstanceQuery.count());
ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.getId());
runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute();
// then
assertEquals(0, sourceHistoryProcessInstanceQuery.count());
assertEquals(1, targetHistoryProcessInstanceQuery.count());
HistoricProcessInstance instance = targetHistoryProcessInstanceQuery.singleResult();
assertEquals(instance.getProcessDefinitionKey(), targetProcessDefinition.getKey());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method testMigrateHistoryVariableInstanceMultiInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testMigrateHistoryVariableInstanceMultiInstance() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_SUBPROCESS_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_SUBPROCESS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
List<HistoricVariableInstance> migratedVariables = historyService.createHistoricVariableInstanceQuery().list();
// 3 loop counter + nrOfInstance + nrOfActiveInstances + nrOfCompletedInstances
Assert.assertEquals(6, migratedVariables.size());
for (HistoricVariableInstance variable : migratedVariables) {
assertEquals(targetDefinition.getKey(), variable.getProcessDefinitionKey());
assertEquals(targetDefinition.getId(), variable.getProcessDefinitionId());
}
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method testMigrateHistoryVariableInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testMigrateHistoryVariableInstance() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId());
runtimeService.setVariable(processInstance.getId(), "test", 3537);
HistoricVariableInstance instance = historyService.createHistoricVariableInstanceQuery().singleResult();
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapActivities("userTask", "userTask").build();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
HistoricVariableInstance migratedInstance = historyService.createHistoricVariableInstanceQuery().singleResult();
assertEquals(targetDefinition.getKey(), migratedInstance.getProcessDefinitionKey());
assertEquals(targetDefinition.getId(), migratedInstance.getProcessDefinitionId());
assertEquals(instance.getActivityInstanceId(), migratedInstance.getActivityInstanceId());
assertEquals(instance.getExecutionId(), migratedInstance.getExecutionId());
}
Aggregations