use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceAuthorizationTest method testSimpleQueryMultiple.
public void testSimpleQueryMultiple() {
// given
startProcessInstanceByKey(PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
// when
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
// then
verifyQueryResults(query, 2);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceAuthorizationTest method testQueryWithReadHistoryPermissionOnProcessDefinition.
public void testQueryWithReadHistoryPermissionOnProcessDefinition() {
// given
startProcessInstanceByKey(PROCESS_KEY);
startProcessInstanceByKey(PROCESS_KEY);
startProcessInstanceByKey(PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
// when
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
// then
verifyQueryResults(query, 6);
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery 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.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceSequenceCounterTest method testSequenceInsideSubProcess.
@Deployment(resources = { "org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testSequenceInsideSubProcess.bpmn20.xml" })
public void testSequenceInsideSubProcess() {
// given
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc();
// when
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// then
query.executionId(processInstanceId);
verifyOrder(query, "theStart", "theService1", "theService2", "theEnd");
String subProcessExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("subProcess").singleResult().getExecutionId();
query.executionId(subProcessExecutionId);
verifyOrder(query, "subProcess", "innerStart", "innerService", "innerEnd");
query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc();
verifyOrder(query, "theStart", "theService1", "subProcess", "innerStart", "innerService", "innerEnd", "theService2", "theEnd");
}
use of org.camunda.bpm.engine.history.HistoricActivityInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricActivityInstanceSequenceCounterTest method testNonInterruptingBoundaryEvent.
@Deployment(resources = { "org/camunda/bpm/engine/test/standalone/entity/ExecutionSequenceCounterTest.testNonInterruptingBoundaryEvent.bpmn20.xml" })
public void testNonInterruptingBoundaryEvent() {
// given
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc();
// when
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
runtimeService.correlateMessage("newMessage");
runtimeService.correlateMessage("newMessage");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
// then
query.executionId(processInstanceId);
verifyOrder(query, "theStart", "theService1", "theEnd1");
String taskExecutionId = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult().getExecutionId();
query.executionId(taskExecutionId);
verifyOrder(query, "theTask");
List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().activityId("messageBoundary").list();
for (HistoricActivityInstance historicActivityInstance : activityInstances) {
query.executionId(historicActivityInstance.getExecutionId());
verifyOrder(query, "messageBoundary", "theServiceAfterMessage", "theEnd2");
}
query = historyService.createHistoricActivityInstanceQuery().orderPartiallyByOccurrence().asc().orderByActivityId().asc();
verifyOrder(query, "theStart", "theService1", "messageBoundary", "theTask", "theServiceAfterMessage", "theEnd2", "messageBoundary", "theServiceAfterMessage", "theEnd2", "theEnd1");
}
Aggregations