use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method noHistoryUpdateOnSameStructureMigration.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void noHistoryUpdateOnSameStructureMigration() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree scopeExecution = executionTreeBeforeMigration.getExecutions().get(0);
runtimeService.setVariableLocal(scopeExecution.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 MigrationHistoricTaskInstanceTest method testMigrateWithSubTask.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateWithSubTask() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
Task task = taskService.createTaskQuery().singleResult();
Task subTask = taskService.newTask();
subTask.setParentTaskId(task.getId());
taskService.saveTask(subTask);
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then the historic sub task instance is still the same
HistoricTaskInstance historicSubTaskAfterMigration = historyService.createHistoricTaskInstanceQuery().taskId(subTask.getId()).singleResult();
Assert.assertNotNull(historicSubTaskAfterMigration);
Assert.assertNull(historicSubTaskAfterMigration.getProcessDefinitionId());
Assert.assertNull(historicSubTaskAfterMigration.getProcessDefinitionKey());
Assert.assertNull(historicSubTaskAfterMigration.getExecutionId());
Assert.assertNull(historicSubTaskAfterMigration.getActivityInstanceId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcInstQueryWithExecutedActivityIds.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcInstQueryWithExecutedActivityIds() {
// given
deployment(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process");
Task task = taskService.createTaskQuery().active().singleResult();
taskService.complete(task.getId());
// assume
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).activityId("userTask1").singleResult();
assertNotNull(historicActivityInstance);
// when
List<HistoricProcessInstance> result = historyService.createHistoricProcessInstanceQuery().executedActivityIdIn(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 testQueryWithRootIncidents.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testQueryWithRootIncidents() {
// given
deployment("org/camunda/bpm/engine/test/history/HistoricProcessInstanceTest.testQueryWithRootIncidents.bpmn20.xml");
deployment(CallActivityModels.oneBpmnCallActivityProcess("Process_1"));
runtimeService.startProcessInstanceByKey("Process");
ProcessInstance calledProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("Process_1").singleResult();
executeAvailableJobs();
// when
List<HistoricProcessInstance> historicProcInstances = historyService.createHistoricProcessInstanceQuery().withRootIncidents().list();
// then
assertNotNull(calledProcessInstance);
assertEquals(1, historicProcInstances.size());
assertEquals(calledProcessInstance.getId(), historicProcInstances.get(0).getId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceTest method testHistoricProcessInstanceQueryIncidentStatusOpenWithTwoProcesses.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldDeleteIncidentAfterJobWasSuccessfully.bpmn" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testHistoricProcessInstanceQueryIncidentStatusOpenWithTwoProcesses() {
// given two processes, which will fail, are started
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("fail", true);
ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("failingProcessWithUserTask", parameters);
runtimeService.startProcessInstanceByKey("failingProcessWithUserTask", parameters);
executeAvailableJobs();
assertEquals(2, historyService.createHistoricProcessInstanceQuery().incidentStatus("open").count());
// when 'fail' variable is set to false, job retry count is set to one
// and available jobs are executed
runtimeService.setVariable(pi1.getId(), "fail", false);
Job jobToResolve = managementService.createJobQuery().processInstanceId(pi1.getId()).singleResult();
managementService.setJobRetries(jobToResolve.getId(), 1);
executeAvailableJobs();
// then query with open and with resolved incidents returns one
assertEquals(1, historyService.createHistoricProcessInstanceQuery().incidentStatus("open").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().incidentStatus("resolved").count());
}
Aggregations