public virtual void testQueryAddAndRemoveIdentityLinksForProcessDefinition() { ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult(); assertNotNull(latestProcessDef); IList <IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.Id); assertEquals(0, links.Count); // Add candiate group with process definition repositoryService.addCandidateStarterGroup(latestProcessDef.Id, GROUP_1); IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 1); // Query test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.processDefinitionId(latestProcessDef.Id).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.Id, USER_1); // Query test query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.processDefinitionId(latestProcessDef.Id).count(), 2); assertEquals(query.processDefinitionKey(latestProcessDef.Key).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.Id, GROUP_1); // Query test query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.processDefinitionId(latestProcessDef.Id).count(), 3); assertEquals(query.processDefinitionKey(latestProcessDef.Key).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.Id, USER_1); // Query test query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.processDefinitionId(latestProcessDef.Id).count(), 4); assertEquals(query.processDefinitionKey(latestProcessDef.Key).count(), 4); assertEquals(query.userId(USER_1).count(), 2); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 2); }
public virtual void testShouldAddClaimTaskCandidateforAddIdentityLink() { // Pre test IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given startProcessInstance(PROCESS_DEFINITION_KEY); string taskId = taskService.createTaskQuery().singleResult().Id; taskService.claim(taskId, A_USER_ID); historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 1); //Query test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(A_USER_ID).count(), 1); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 1); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 0); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 1); }
public virtual void testInvalidGroupQueryTaskCandidateForAddAndDeleteIdentityLink() { IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given startProcessInstance(PROCESS_DEFINITION_KEY); string taskId = taskService.createTaskQuery().singleResult().Id; // if identityService.AuthenticatedUserId = A_ASSIGNER_ID; taskService.addCandidateUser(taskId, A_USER_ID); taskService.deleteCandidateUser(taskId, A_USER_ID); // Invalid Individual Query test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.taskId(INVALID_TASK_ID).count(), 0); assertEquals(query.type(INVALID_IDENTITY_LINK_TYPE).count(), 0); assertEquals(query.userId(INVALID_USER_ID).count(), 0); assertEquals(query.groupId(INVALID_GROUP_ID).count(), 0); assertEquals(query.assignerId(INVALID_ASSIGNER_ID).count(), 0); assertEquals(query.operationType(INVALID_HISTORY_EVENT_TYPE).count(), 0); assertEquals(query.processDefinitionId(INVALID_PROCESS_DEFINITION_ID).count(), 0); assertEquals(query.processDefinitionKey(INVALID_PROCESS_DEFINITION_KEY).count(), 0); }
public virtual void testValidGroupQueryTaskCandidateForAddAndDeleteIdentityLink() { IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY); string taskId = taskService.createTaskQuery().singleResult().Id; // if identityService.AuthenticatedUserId = 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.ProcessDefinitionId).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); }
public virtual void testShouldAddMultipleDelegateTaskCandidateforAddIdentityLink() { // Pre test IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given startProcessInstance(PROCESS_DEFINITION_KEY); string taskId = taskService.createTaskQuery().singleResult().Id; identityService.AuthenticatedUserId = A_ASSIGNER_ID; taskService.addUserIdentityLink(taskId, A_USER_ID, IdentityLinkType.ASSIGNEE); taskService.delegateTask(taskId, B_USER_ID); taskService.delegateTask(taskId, C_USER_ID); taskService.deleteUserIdentityLink(taskId, C_USER_ID, IdentityLinkType.ASSIGNEE); historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); // Addition of A_USER, Deletion of A_USER, Addition of A_USER as owner, // Addition of B_USER, Deletion of B_USER, Addition of C_USER, Deletion of C_USER assertEquals(historicIdentityLinks.Count, 7); //Query test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(A_USER_ID).count(), 3); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(B_USER_ID).count(), 2); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(C_USER_ID).count(), 2); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 4); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 3); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 6); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.type(IdentityLinkType.OWNER).count(), 1); }
public virtual void testShouldAddIdentityLinkForTaskCreationWithAssigneeAndOwner() { string taskAssigneeId = "Assigneee"; string taskOwnerId = "Owner"; // Pre test IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); Task taskAssignee = taskService.newTask(taskAssigneeId); taskAssignee.Assignee = USER_1; taskService.saveTask(taskAssignee); Task taskOwner = taskService.newTask(taskOwnerId); taskOwner.Owner = OWNER_1; taskService.saveTask(taskOwner); Task taskEmpty = taskService.newTask(); taskService.saveTask(taskEmpty); // then historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 2); // Basic Query test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 1); assertEquals(query.userId(USER_1).count(), 1); query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.type(IdentityLinkType.OWNER).count(), 1); assertEquals(query.userId(OWNER_1).count(), 1); taskService.deleteTask(taskAssigneeId, true); taskService.deleteTask(taskOwnerId, true); taskService.deleteTask(taskEmpty.Id, true); }
public virtual void testShouldAddTaskAssigneeforAddIdentityLinkUsingXml() { // Pre test IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given startProcessInstance(PROCESS_DEFINITION_KEY_ASSIGNEE); historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 1); // query Test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(XML_ASSIGNEE).count(), 1); }
public virtual void testShouldAddProcessCandidateStarterUserforAddIdentityLinkUsingXml() { // Pre test - Historical identity link is added as part of deployment IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 1); // given ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_CANDIDATE_STARTER_USER).singleResult(); assertNotNull(latestProcessDef); IList <IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.Id); assertEquals(1, links.Count); historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 1); // query Test HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.userId(XML_USER).count(), 1); }