use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class APITaskConverterTest method should_returnCandidates_when_convertATaskWithCandidates.
@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"));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class APITaskConverterTest method should_convertTask_when_appVersionNull.
@Test
public void should_convertTask_when_appVersionNull() {
Task convertedTask = taskConverter.from(taskBuilder().withAppVersion(null).build());
assertThat(convertedTask).isNotNull().extracting(Task::getAppVersion).isNull();
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeImplTest method should_returnResultOfHelper_when_updateTask.
@Test
public void should_returnResultOfHelper_when_updateTask() {
// given
UpdateTaskPayload updateTaskPayload = TaskPayloadBuilder.update().withTaskId("taskId").withDescription("new description").build();
TaskImpl updatedTask = new TaskImpl();
given(taskRuntimeHelper.applyUpdateTaskPayload(false, updateTaskPayload)).willReturn(updatedTask);
// when
Task retrievedTask = taskRuntime.update(updateTaskPayload);
// then
assertThat(retrievedTask).isEqualTo(updatedTask);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskAdminRuntimeImpl method complete.
@Override
public Task complete(CompleteTaskPayload completeTaskPayload) {
Task task = task(completeTaskPayload.getTaskId());
if (task == null) {
throw new IllegalStateException("Task with id: " + completeTaskPayload.getTaskId() + " cannot be completed because it cannot be found.");
}
taskRuntimeHelper.handleCompleteTaskPayload(completeTaskPayload);
TaskImpl competedTaskData = new TaskImpl(task.getId(), task.getName(), Task.TaskStatus.COMPLETED);
taskService.complete(completeTaskPayload.getTaskId(), completeTaskPayload.getVariables(), true);
return competedTaskData;
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeImpl method release.
@Override
public Task release(ReleaseTaskPayload releaseTaskPayload) {
// Validate that the task is visible by the currently authorized user
Task task;
try {
task = task(releaseTaskPayload.getTaskId());
} catch (IllegalStateException ex) {
throw new IllegalStateException("The authenticated user cannot release task" + releaseTaskPayload.getTaskId() + " due it is not a candidate for it");
}
// validate the the task doesn't have an assignee
if (task.getAssignee() == null || task.getAssignee().isEmpty()) {
throw new IllegalStateException("You cannot release a task that is not claimed");
}
String authenticatedUserId = securityManager.getAuthenticatedUserId();
// validate that you are trying to release task where you are the assignee
if (!task.getAssignee().equals(authenticatedUserId)) {
throw new IllegalStateException("You cannot release a task where you are not the assignee");
}
taskService.unclaim(releaseTaskPayload.getTaskId());
return task(releaseTaskPayload.getTaskId());
}
Aggregations