未验证 提交 19a32c38 编写于 作者: S salaboy 提交者: GitHub

Merge pull request #2455 from...

Merge pull request #2455 from Activiti/CTI777-1953-Task-name-required-to-create-a-task-in-Java-and-REST-apis

Task name required when creating a task
......@@ -249,6 +249,10 @@ public class TaskRuntimeImpl implements TaskRuntime {
@Override
public Task create(CreateTaskPayload createTaskPayload) {
if (createTaskPayload.getName() == null || createTaskPayload.getName().isEmpty()) {
throw new IllegalStateException("You cannot create a task without name");
}
org.activiti.engine.task.Task task = taskService.newTask();
task.setName(createTaskPayload.getName());
task.setDescription(createTaskPayload.getDescription());
......
package org.activiti.spring.boot.tasks;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import org.activiti.api.runtime.shared.query.Page;
import org.activiti.api.runtime.shared.query.Pageable;
import org.activiti.api.task.model.Task;
......@@ -16,8 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class TaskRuntimeStandaloneTaskTest {
......@@ -115,5 +116,26 @@ public class TaskRuntimeStandaloneTaskTest {
}
@Test
public void createStandaloneTaskFailWithEmptyName() {
securityUtil.logInAs("salaboy");
//when
Throwable throwable = catchThrowable(() -> taskRuntime.create(TaskPayloadBuilder.create()
.withAssignee("salaboy")
.build()));
//then
assertThat(throwable)
.isInstanceOf(IllegalStateException.class);
Page<Task> tasks = taskRuntime.tasks(Pageable.of(0,
50));
assertThat(tasks.getContent()).hasSize(0);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册