use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testSimpleQueryWithoutAuthorization.
// process instance query //////////////////////////////////////////////////////////
public void testSimpleQueryWithoutAuthorization() {
// given
startProcessInstanceByKey(PROCESS_KEY);
// when
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
// then
verifyQueryResults(query, 0);
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testQueryWithReadPermissionOnProcessInstance.
public void testQueryWithReadPermissionOnProcessInstance() {
// given
startProcessInstanceByKey(PROCESS_KEY);
startProcessInstanceByKey(PROCESS_KEY);
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ);
// when
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
// then
verifyQueryResults(query, 1);
ProcessInstance instance = query.singleResult();
assertNotNull(instance);
assertEquals(processInstanceId, instance.getId());
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceSyncQueryTest method testMigrateWithQuery.
@Test
public void testMigrateWithQuery() {
// 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 instance1 = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
ProcessInstance instance2 = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
grantAuthorization("user", Resources.PROCESS_INSTANCE, instance2.getId(), Permissions.READ);
grantAuthorization("user", Resources.PROCESS_DEFINITION, "*", Permissions.MIGRATE_INSTANCE);
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
ProcessInstanceQuery query = engineRule.getRuntimeService().createProcessInstanceQuery();
// when
authRule.enableAuthorization("user");
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceQuery(query).execute();
authRule.disableAuthorization();
// then
ProcessInstance instance1AfterMigration = engineRule.getRuntimeService().createProcessInstanceQuery().processInstanceId(instance1.getId()).singleResult();
Assert.assertEquals(sourceDefinition.getId(), instance1AfterMigration.getProcessDefinitionId());
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class DeleteProcessInstancesBatchAuthorizationTest method testWithQuery.
@Test
public void testWithQuery() {
// given
ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceIds(new HashSet<String>(Arrays.asList(processInstance.getId(), processInstance2.getId())));
authRule.init(scenario).withUser("userId").bindResource("processInstance1", processInstance.getId()).bindResource("processInstance2", processInstance2.getId()).bindResource("Process_2", sourceDefinition2.getKey()).start();
// when
batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery, TEST_REASON);
executeSeedAndBatchJobs();
// then
if (authRule.assertScenario(scenario)) {
if (testHelper.isHistoryLevelFull()) {
assertThat(engineRule.getHistoryService().createUserOperationLogQuery().count(), is(BATCH_OPERATIONS));
}
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testSimpleQueryWithReadPermissionOnAnyProcessInstance.
public void testSimpleQueryWithReadPermissionOnAnyProcessInstance() {
// given
String processInstanceId = startProcessInstanceByKey(PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_INSTANCE, ANY, userId, READ);
// when
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
// then
verifyQueryResults(query, 1);
ProcessInstance instance = query.singleResult();
assertNotNull(instance);
assertEquals(processInstanceId, instance.getId());
}
Aggregations