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 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 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 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 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 testShouldAddTaskOwnerForAddandDeleteIdentityLinkByTimeStamp() { IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list(); assertEquals(historicIdentityLinks.Count, 0); // given startProcessInstance(PROCESS_DEFINITION_KEY); string taskId = taskService.createTaskQuery().singleResult().Id; // if ClockUtil.CurrentTime = newYearMorning(0); identityService.AuthenticatedUserId = A_ASSIGNER_ID; // Adds aUserId1, deletes aUserID1, adds aUserId2, deletes aUserId2, Adds aUserId3 - 5 addUserIdentityLinks(taskId); ClockUtil.CurrentTime = newYearNoon(0); //Deletes aUserId3 deleteUserIdentityLinks(taskId); ClockUtil.CurrentTime = newYearNoon(30); addUserIdentityLinks(taskId); ClockUtil.CurrentTime = newYearEvening(); deleteUserIdentityLinks(taskId); // Query records with time before 12:20 HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.dateBefore(newYearNoon(20)).count(), 6); assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 3); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 3); // Query records with time between 00:01 and 12:00 query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.dateBefore(newYearNoon(0)).count(), 6); assertEquals(query.dateAfter(newYearMorning(1)).count(), 1); assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 0); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1); // Query records with time after 12:45 query = historyService.createHistoricIdentityLinkLogQuery(); assertEquals(query.dateAfter(newYearNoon(45)).count(), 1); assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 0); assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1); ClockUtil.CurrentTime = DateTime.Now; }