TSK-1894: set manual priority to default in rest

This commit is contained in:
ryzheboka 2022-05-27 17:07:44 +02:00 committed by Elena Mokeeva
parent 691370f096
commit 3bbd7446e2
4 changed files with 31 additions and 3 deletions

View File

@ -15,6 +15,8 @@ import pro.taskana.workbasket.api.models.WorkbasketSummary;
*/
public interface TaskSummary {
public static int DEFAULT_MANUAL_PRIORITY = -1;
/**
* Returns the id of the {@linkplain Task}.
*

View File

@ -21,8 +21,6 @@ import pro.taskana.workbasket.internal.models.WorkbasketSummaryImpl;
/** Entity which contains the most important information about a Task. */
public class TaskSummaryImpl implements TaskSummary {
private static final int DEFAULT_MANUAL_PRIORITY = -1;
protected String id;
protected String externalId;
protected Instant received;

View File

@ -1,5 +1,7 @@
package pro.taskana.task.rest.models;
import static pro.taskana.task.api.models.TaskSummary.DEFAULT_MANUAL_PRIORITY;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@ -59,7 +61,7 @@ public class TaskSummaryRepresentationModel
* priority is automatically set to manualPriority. In this case, all computations of priority are
* disabled. If the value of manualPriority is negative, Tasks are not prioritized manually.
*/
protected int manualPriority;
protected int manualPriority = DEFAULT_MANUAL_PRIORITY;
/** The current task state. */
protected TaskState state;
/** The classification of this task. */

View File

@ -749,6 +749,32 @@ class TaskControllerIntTest {
assertThat(responseDeleted.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
@Test
void should_CreateTaskWithCorrectPriorityAndThenDeleteIt_When_NotSpecifyingManualPriority() {
TaskRepresentationModel taskRepresentationModel = getTaskResourceSample();
String url = restHelper.toUrl(RestEndpoints.URL_TASKS);
HttpEntity<TaskRepresentationModel> auth =
new HttpEntity<>(taskRepresentationModel, RestHelper.generateHeadersForUser("teamlead-1"));
ResponseEntity<TaskRepresentationModel> responseCreate =
TEMPLATE.exchange(url, HttpMethod.POST, auth, TASK_MODEL_TYPE);
assertThat(responseCreate.getStatusCode()).isEqualTo(HttpStatus.CREATED);
assertThat(responseCreate.getBody()).isNotNull();
// The classification of taskRepresentationModel with the key "L11010" has priority=1
assertThat(responseCreate.getBody().getPriority()).isEqualTo(1);
assertThat(responseCreate.getBody().getManualPriority()).isEqualTo(-1);
String taskIdOfCreatedTask = responseCreate.getBody().getTaskId();
String url2 = restHelper.toUrl(RestEndpoints.URL_TASKS_ID, taskIdOfCreatedTask);
HttpEntity<Object> auth2 = new HttpEntity<>(RestHelper.generateHeadersForUser("admin"));
ResponseEntity<TaskRepresentationModel> responseDeleted =
TEMPLATE.exchange(
url2, HttpMethod.DELETE, auth2, ParameterizedTypeReference.forType(Void.class));
assertThat(responseDeleted.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
@Test
void should_GetPriorityCorrectly_When_GettingTaskWithManualPriority() {
String url =