use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeStandaloneTaskTest method should_throwExceptionOnCreateVariable_when_charactersNotAllowedInVariableName.
@Test
public void should_throwExceptionOnCreateVariable_when_charactersNotAllowedInVariableName() {
securityUtil.logInAs("user");
Task task = taskRuntime.create(TaskPayloadBuilder.create().withName("name").withAssignee("user").build());
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Throwable throwable = catchThrowable(() -> taskRuntime.createVariable(TaskPayloadBuilder.createVariable().withTaskId(task.getId()).withVariable("!wrong_name", "value").build()));
assertThat(throwable).isInstanceOf(IllegalStateException.class);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeStandaloneTaskTest method shouldEmmitEventForStandAloneTaskDeletion.
@Test
public void shouldEmmitEventForStandAloneTaskDeletion() {
// given
securityUtil.logInAs("user");
Task firstTask = taskRuntime.create(TaskPayloadBuilder.create().withName("First task").withAssignee("user").build());
Task secondTask = taskRuntime.create(TaskPayloadBuilder.create().withName("Second task").withAssignee("user").build());
// when
taskRuntime.delete(TaskPayloadBuilder.delete().withTaskId(secondTask.getId()).build());
// then
assertThat(taskRuntimeEventListeners.getCancelledTasks()).extracting(Task::getId, Task::getName).contains(tuple(secondTask.getId(), secondTask.getName())).doesNotContain(tuple(firstTask.getId(), firstTask.getName()));
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeStandaloneTaskTest method should_throwExceptionOnTaskComplete_when_charactersNotAllowedInVariableName.
@Test
public void should_throwExceptionOnTaskComplete_when_charactersNotAllowedInVariableName() {
securityUtil.logInAs("user");
Task task = taskRuntime.create(TaskPayloadBuilder.create().withName("name").withAssignee("user").build());
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 50));
assertThat(tasks.getContent()).hasSize(1);
Map<String, Object> variables = new HashMap<>();
variables.put("var_name1", "good_value");
variables.put("!wrong_name", "!any_value>");
Throwable throwable = catchThrowable(() -> taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).withVariables(variables).build()));
assertThat(throwable).isInstanceOf(IllegalStateException.class);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class TaskRuntimeUnAuthorizedTest method createStandaloneTaskForGroup.
@Test
public void createStandaloneTaskForGroup() {
securityUtil.logInAs("garth");
Task standAloneTask = taskRuntime.create(TaskPayloadBuilder.create().withName("group task").withCandidateGroup("doctor").build());
// the owner should be able to see the created task
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 should throw a NotFoundException due you are not a candidate
securityUtil.logInAs("user");
// when
Throwable throwable = catchThrowable(() -> taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build()));
// then
assertThat(throwable).isInstanceOf(NotFoundException.class);
}
use of org.activiti.api.task.model.Task in project Activiti by Activiti.
the class ProcessRuntimeBPMNTimerIT method shouldGetTimerCanceledEventOnBoundaryEvent.
@Test
public void shouldGetTimerCanceledEventOnBoundaryEvent() {
// given
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey(PROCESS_TIMER_CANCELLED_EVENT);
List<BPMNTimerScheduledEvent> eventsScheduled = listenerScheduled.getEvents();
assertThat(eventsScheduled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_SCHEDULED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
clear();
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10), TaskPayloadBuilder.tasks().withProcessInstanceId(processInstance.getId()).build());
assertThat(tasks.getContent()).hasSize(1);
Task task = tasks.getContent().get(0);
taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build());
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build());
List<BPMNTimerCancelledEvent> eventsCanceled = listenerCancelled.getEvents();
assertThat(eventsCanceled).extracting(BPMNTimerEvent::getEventType, BPMNTimerEvent::getProcessDefinitionId, event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId(), event -> event.getEntity().getElementId()).contains(Tuple.tuple(BPMNTimerEvent.TimerEvents.TIMER_CANCELLED, processInstance.getProcessDefinitionId(), processInstance.getProcessDefinitionId(), processInstance.getId(), "timer"));
}
Aggregations