コード例 #1
0
        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);
        }
コード例 #2
0
        public virtual void testShouldAddIdentityLinkByProcessDefinitionAndStandalone()
        {
            string taskAssigneeId = "Assigneee";
            // Pre test
            IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();

            assertEquals(historicIdentityLinks.Count, 0);

            ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY);
            string          taskId          = taskService.createTaskQuery().singleResult().Id;

            // given
            Task taskAssignee = taskService.newTask(taskAssigneeId);

            taskAssignee.Assignee = USER_1;
            taskService.saveTask(taskAssignee);

            // if
            addAndDeleteUserWithAssigner(taskId, IdentityLinkType.ASSIGNEE);

            // then
            historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
            assertEquals(historicIdentityLinks.Count, 3);

            // Basic Query test
            HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

            assertEquals(query.type(IdentityLinkType.ASSIGNEE).count(), 3);

            query = historyService.createHistoricIdentityLinkLogQuery();
            assertEquals(query.processDefinitionId(processInstance.ProcessDefinitionId).count(), 2);
            assertEquals(query.processDefinitionKey(PROCESS_DEFINITION_KEY).count(), 2);

            taskService.deleteTask(taskAssigneeId, true);
        }
コード例 #3
0
        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);
        }
コード例 #4
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);
        }