TSK-1943: added REST endpoint for force requesting a review on a Task
This commit is contained in:
parent
6997d64083
commit
5f4923fe0a
|
@ -105,6 +105,7 @@ include::{snippets}/TaskControllerRestDocTest/selectAndClaimTaskDocTest/auto-sec
|
|||
include::{snippets}/TaskControllerRestDocTest/cancelClaimTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/forceCancelClaimTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/requestReviewTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/forceRequestReviewTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/requestChangesTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/forceRequestChangesTaskDocTest/auto-section.adoc[]
|
||||
include::{snippets}/TaskControllerRestDocTest/completeTaskDocTest/auto-section.adoc[]
|
||||
|
|
|
@ -47,6 +47,8 @@ public final class RestEndpoints {
|
|||
public static final String URL_TASKS_ID_CLAIM_FORCE = API_V1 + "tasks/{taskId}/claim/force";
|
||||
public static final String URL_TASKS_ID_SELECT_AND_CLAIM = API_V1 + "tasks/select-and-claim";
|
||||
public static final String URL_TASKS_ID_REQUEST_REVIEW = API_V1 + "tasks/{taskId}/request-review";
|
||||
public static final String URL_TASKS_ID_REQUEST_REVIEW_FORCE =
|
||||
API_V1 + "tasks/{taskId}/request-review/force";
|
||||
public static final String URL_TASKS_ID_REQUEST_CHANGES =
|
||||
API_V1 + "tasks/{taskId}/request-changes";
|
||||
public static final String URL_TASKS_ID_REQUEST_CHANGES_FORCE =
|
||||
|
|
|
@ -224,6 +224,27 @@ public class TaskController {
|
|||
return ResponseEntity.ok(taskRepresentationModelAssembler.toModel(task));
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint force request a review on the specified Task.
|
||||
*
|
||||
* @param taskId taskId the id of the relevant Task
|
||||
* @return the Task after a review has been requested
|
||||
* @throws InvalidTaskStateException if the state of the Task with taskId is not CLAIMED
|
||||
* @throws TaskNotFoundException if the Task with taskId wasn't found
|
||||
* @throws InvalidOwnerException cannot be thrown
|
||||
* @throws NotAuthorizedException if the current user has no READ permissions for the Workbasket
|
||||
* the Task is in
|
||||
* @title Force request a review on a Task
|
||||
*/
|
||||
@PostMapping(path = RestEndpoints.URL_TASKS_ID_REQUEST_REVIEW_FORCE)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<TaskRepresentationModel> forceRequestReview(@PathVariable String taskId)
|
||||
throws InvalidTaskStateException, TaskNotFoundException, InvalidOwnerException,
|
||||
NotAuthorizedException {
|
||||
Task task = taskService.forceRequestReview(taskId);
|
||||
return ResponseEntity.ok(taskRepresentationModelAssembler.toModel(task));
|
||||
}
|
||||
|
||||
/**
|
||||
* This endpoint request changes on the specified Task.
|
||||
*
|
||||
|
|
|
@ -1420,6 +1420,35 @@ class TaskControllerIntTest {
|
|||
assertThat(repModel.getState()).isEqualTo(TaskState.READY_FOR_REVIEW);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_ForceRequestReview_When_CurrentUserIsNotTheOwner() {
|
||||
String url =
|
||||
restHelper.toUrl(RestEndpoints.URL_TASKS_ID, "TKI:000000000000000000000000000000000101");
|
||||
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("user-1-1"));
|
||||
|
||||
// retrieve task from Rest Api
|
||||
ResponseEntity<TaskRepresentationModel> getTaskResponse =
|
||||
TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_MODEL_TYPE);
|
||||
assertThat(getTaskResponse.getBody()).isNotNull();
|
||||
TaskRepresentationModel repModel = getTaskResponse.getBody();
|
||||
assertThat(repModel.getState()).isEqualTo(TaskState.CLAIMED);
|
||||
assertThat(repModel.getOwner()).isEqualTo("user-1-2");
|
||||
|
||||
// request review
|
||||
String url2 =
|
||||
restHelper.toUrl(
|
||||
RestEndpoints.URL_TASKS_ID_REQUEST_REVIEW_FORCE,
|
||||
"TKI:000000000000000000000000000000000101");
|
||||
ResponseEntity<TaskRepresentationModel> requestReviewResponse =
|
||||
TEMPLATE.exchange(url2, HttpMethod.POST, auth, TASK_MODEL_TYPE);
|
||||
|
||||
assertThat(requestReviewResponse.getBody()).isNotNull();
|
||||
assertThat(requestReviewResponse.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
repModel = requestReviewResponse.getBody();
|
||||
assertThat(repModel.getOwner()).isNull();
|
||||
assertThat(repModel.getState()).isEqualTo(TaskState.READY_FOR_REVIEW);
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_RequestChangesOnATask() {
|
||||
String url =
|
||||
|
|
|
@ -91,6 +91,17 @@ class TaskControllerRestDocTest extends BaseRestDocTest {
|
|||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void forceRequestReviewTaskDocTest() throws Exception {
|
||||
mockMvc
|
||||
.perform(
|
||||
post(
|
||||
RestEndpoints.URL_TASKS_ID_REQUEST_REVIEW_FORCE,
|
||||
"TKI:000000000000000000000000000000000101")
|
||||
.headers(RestHelper.generateHeadersForUser("user-1-2")))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestChangesTaskDocTest() throws Exception {
|
||||
mockMvc
|
||||
|
|
Loading…
Reference in New Issue