APITaskConverter extends ListConverter<org.activiti.engine.task.Task, Task> implements ModelConverter<org.activiti.engine.task.Task, Task> { public Task fromWithCandidates(org.activiti.engine.task.Task internalTask) { TaskImpl task = buildFromInternalTask(internalTask, calculateStatus(internalTask)); extractCandidateUsersAndGroups(internalTask, task); return task; } @Autowired  APITaskConverter(TaskService taskService); @Override Task from(org.activiti.engine.task.Task internalTask); Task fromWithCandidates(org.activiti.engine.task.Task internalTask); Task from(org.activiti.engine.task.Task internalTask,
        Task.TaskStatus status); Task fromWithCompletedBy(org.activiti.engine.task.Task internalTask,
        Task.TaskStatus status, String completedBy);  }
@Test public void should_returnCandidates_when_convertATaskWithCandidates() { given(taskService.getIdentityLinksForTask(any())) .willReturn(asList( buildIdentityLink(null, "group1", IdentityLinkType.CANDIDATE), buildIdentityLink("user1", null, IdentityLinkType.CANDIDATE), buildIdentityLink(null, "participant", IdentityLinkType.PARTICIPANT), buildIdentityLink("user2", null, IdentityLinkType.CANDIDATE))); org.activiti.engine.task.Task source = taskBuilder() .withId("1111") .build(); Task convertedTask = taskConverter.fromWithCandidates(source); assertThat(convertedTask) .isNotNull(); assertThat(convertedTask.getCandidateGroups()).hasSize(1); assertThat(convertedTask.getCandidateGroups()).containsExactlyInAnyOrder("group1"); assertThat(convertedTask.getCandidateUsers()).hasSize(2); assertThat(convertedTask.getCandidateUsers()).containsExactlyInAnyOrder("user1", "user2"); verify(taskService).getIdentityLinksForTask(eq("1111")); }