use of org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogAuthorizationTest method testQueryForTaskHistoricIdentityLinkWithUserPermission.
public void testQueryForTaskHistoricIdentityLinkWithUserPermission() {
// given
disableAuthorization();
startProcessInstanceByKey(ONE_PROCESS_KEY);
// if
createGrantAuthorization(PROCESS_DEFINITION, ONE_PROCESS_KEY, userId, READ_HISTORY);
enableAuthorization();
// when
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
// then
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogAuthorizationTest method testQueryCaseTask.
public void testQueryCaseTask() {
// given
createCaseInstanceByKey(CASE_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId("aAssignerId");
taskService.addCandidateUser(taskId, "aUserId");
enableAuthorization();
// when
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
// then
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogQueryTest method testValidGroupQueryTaskCandidateForAddAndDeleteIdentityLink.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testValidGroupQueryTaskCandidateForAddAndDeleteIdentityLink() {
List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
assertEquals(historicIdentityLinks.size(), 0);
// given
ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY);
String taskId = taskService.createTaskQuery().singleResult().getId();
// if
identityService.setAuthenticatedUserId(A_ASSIGNER_ID);
taskService.addCandidateUser(taskId, A_USER_ID);
taskService.deleteCandidateUser(taskId, A_USER_ID);
// Valid group query test
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.taskId(taskId).count(), 2);
assertEquals(query.type(IdentityLinkType.CANDIDATE).count(), 2);
assertEquals(query.userId(A_USER_ID).count(), 2);
assertEquals(query.assignerId(A_ASSIGNER_ID).count(), 2);
assertEquals(query.processDefinitionId(processInstance.getProcessDefinitionId()).count(), 2);
assertEquals(query.processDefinitionKey(PROCESS_DEFINITION_KEY).count(), 2);
assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);
assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 1);
}
use of org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogQueryTest method testQueryAddAndRemoveIdentityLinksForProcessDefinition.
@SuppressWarnings("deprecation")
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryAddAndRemoveIdentityLinksForProcessDefinition() throws Exception {
ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
assertNotNull(latestProcessDef);
List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
// Add candiate group with process definition
repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), GROUP_1);
List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
assertEquals(historicIdentityLinks.size(), 1);
// Query test
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 1);
assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 1);
assertEquals(query.groupId(GROUP_1).count(), 1);
// Add candidate user for process definition
repositoryService.addCandidateStarterUser(latestProcessDef.getId(), USER_1);
// Query test
query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 2);
assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 2);
assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 2);
assertEquals(query.userId(USER_1).count(), 1);
// Delete candiate group with process definition
repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), GROUP_1);
// Query test
query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 3);
assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 3);
assertEquals(query.groupId(GROUP_1).count(), 2);
assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);
// Delete candidate user for process definition
repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), USER_1);
// Query test
query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 4);
assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 4);
assertEquals(query.userId(USER_1).count(), 2);
query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 2);
}
use of org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogQueryTest method testHistoricIdentityLinkQueryPaging.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/OneTaskProcessWithMultipleCandidateUser.bpmn20.xml" })
public void testHistoricIdentityLinkQueryPaging() {
startProcessInstance(PROCESS_DEFINITION_KEY_MULTIPLE_CANDIDATE_USER);
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(4, query.listPage(0, 4).size());
assertEquals(1, query.listPage(2, 1).size());
assertEquals(2, query.listPage(1, 2).size());
assertEquals(3, query.listPage(1, 4).size());
}
Aggregations