Java Code Examples for org.flowable.engine.TaskService#addCandidateUser()

The following examples show how to use org.flowable.engine.TaskService#addCandidateUser() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryServiceTaskLogTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void logAddCandidateUser(RuntimeService runtimeService, TaskService taskService, HistoryService historyService,
        ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    try {
        assertThat(processInstance).isNotNull();
        assertThat(task).isNotNull();

        taskService.addCandidateUser(task.getId(), "newCandidateUser");

        if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) {
            List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list();
            assertThat(logEntries).hasSize(2);

            logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId())
                    .type("USER_TASK_IDENTITY_LINK_ADDED")
                    .list();
            assertThat(logEntries).hasSize(1);
            assertThat(logEntries.get(0).getData()).contains(
                    "\"type\":\"candidate\"",
                    "\"userId\":\"newCandidateUser\""
            );
        }

    } finally {
        taskService.complete(task.getId());
        deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId());
    }
}
 
Example 2
Source File: HistoryServiceTaskLogTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
@Deployment(resources = { "org/flowable/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void logDeleteCandidateUser(RuntimeService runtimeService, TaskService taskService, HistoryService historyService,
        ManagementService managementService, ProcessEngineConfiguration processEngineConfiguration) {

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertThat(processInstance).isNotNull();
    assertThat(task).isNotNull();
    taskService.addCandidateUser(task.getId(), "newCandidateUser");

    try {
        taskService.deleteCandidateUser(task.getId(), "newCandidateUser");

        if (HistoryTestHelper.isHistoricTaskLoggingEnabled(processEngineConfiguration)) {
            List<HistoricTaskLogEntry> logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list();
            assertThat(logEntries).hasSize(3);

            logEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId())
                    .type("USER_TASK_IDENTITY_LINK_REMOVED")
                    .list();
            assertThat(logEntries).hasSize(1);
            assertThat(logEntries.get(0).getData()).contains(
                    "\"type\":\"candidate\"",
                    "\"userId\":\"newCandidateUser\""
            );
        }

    } finally {
        taskService.complete(task.getId());
        deleteTaskWithLogEntries(taskService, managementService, processEngineConfiguration, task.getId());
    }
}