use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskBaseRuntime method completeTask.
public void completeTask(String taskId, Map<String, Object> variables) {
Task completeTask = taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskId).withVariables(variables).build());
assertThat(completeTask).isNotNull();
assertThat(completeTask.getStatus()).isEqualTo(TaskStatus.COMPLETED);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeAppVersionIT method should_standaloneTaskAlwaysHaveAppVersion.
@Test
public void should_standaloneTaskAlwaysHaveAppVersion() {
securityUtil.logInAs("user");
taskRuntime.create(TaskPayloadBuilder.create().withName("new task").build());
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Task result = tasks.getContent().get(0);
assertThat(result.getName()).isEqualTo("new task");
assertThat(result.getAppVersion()).isEqualTo("1");
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeClaimReleaseTest method should_throwIllegalStateException_when_releaseNotClaimedAndAssignedTask.
@Test
public void should_throwIllegalStateException_when_releaseNotClaimedAndAssignedTask() {
securityUtil.logInAs("garth");
Task standAloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateUsers("garth").withCandidateGroup("activitiTeam").build());
assertThat(standAloneTask.getAssignee()).isNull();
assertThat(standAloneTask.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
Throwable thrown = catchThrowable(() -> {
// UnAuthorized release, task is not assigned
taskRuntime.release(TaskPayloadBuilder.release().withTaskId(standAloneTask.getId()).build());
});
assertThat(thrown).isInstanceOf(IllegalStateException.class).hasMessage("You cannot release a task that is not claimed");
;
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeClaimReleaseTest method should_claimAndRelease_when_userIsInCandidateGroup.
@Test
public void should_claimAndRelease_when_userIsInCandidateGroup() {
securityUtil.logInAs("garth");
Task standAloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateGroup("activitiTeam").build());
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
assertThat(task.getAssignee()).isNull();
assertThat(task.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
// Claim and Release
securityUtil.logInAs("user");
Task claimedTask = taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
assertThat(claimedTask.getAssignee()).isEqualTo("user");
assertThat(claimedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
assertThat(claimedTask.getTaskDefinitionKey()).isNull();
Task releasedTask = taskRuntime.release(TaskPayloadBuilder.release().withTaskId(claimedTask.getId()).build());
assertThat(releasedTask.getAssignee()).isNull();
assertThat(releasedTask.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeClaimReleaseTest method should_throwNotFoundException_when_releaseTaskNotAssignedToLoggedUser.
@Test
public void should_throwNotFoundException_when_releaseTaskNotAssignedToLoggedUser() {
securityUtil.logInAs("garth");
Task standAloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateGroup("activitiTeam").build());
assertThat(standAloneTask.getAssignee()).isNull();
assertThat(standAloneTask.getStatus()).isEqualTo(Task.TaskStatus.CREATED);
securityUtil.logInAs("user");
// Claim task
Task claimedTask = taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(standAloneTask.getId()).build());
assertThat(claimedTask.getAssignee()).isEqualTo("user");
assertThat(claimedTask.getStatus()).isEqualTo(Task.TaskStatus.ASSIGNED);
// UnAuthorized release, task is assigned not to you and hence not visible anymore
securityUtil.logInAs("john");
Throwable throwable = catchThrowable(() -> taskRuntime.release(TaskPayloadBuilder.release().withTaskId(standAloneTask.getId()).build()));
// then
assertThat(throwable).isInstanceOf(NotFoundException.class).hasMessage("Unable to find task for the given id: " + standAloneTask.getId() + " for user: john (with groups: [activitiTeam] & with roles: [ACTIVITI_USER])");
}
Aggregations