TSK-1150: now returning 404 StatusCode for TaskCommentNotFoundException

This commit is contained in:
Mustapha Zorgati 2020-03-18 20:53:25 +01:00 committed by Holger Hagen
parent 93a94f0458
commit 4eba81bd57
2 changed files with 4 additions and 18 deletions

View File

@ -14,21 +14,19 @@ import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import pro.taskana.classification.api.exceptions.ClassificationAlreadyExistException;
import pro.taskana.classification.api.exceptions.ClassificationNotFoundException;
import pro.taskana.common.api.exceptions.ConcurrencyException;
import pro.taskana.common.api.exceptions.DomainNotFoundException;
import pro.taskana.common.api.exceptions.InvalidArgumentException;
import pro.taskana.common.api.exceptions.NotAuthorizedException;
import pro.taskana.common.api.exceptions.NotFoundException;
import pro.taskana.task.api.exceptions.InvalidOwnerException;
import pro.taskana.task.api.exceptions.InvalidStateException;
import pro.taskana.task.api.exceptions.TaskAlreadyExistException;
import pro.taskana.task.api.exceptions.TaskNotFoundException;
import pro.taskana.workbasket.api.exceptions.InvalidWorkbasketException;
import pro.taskana.workbasket.api.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.workbasket.api.exceptions.WorkbasketAccessItemAlreadyExistException;
import pro.taskana.workbasket.api.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.workbasket.api.exceptions.WorkbasketInUseException;
import pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException;
/**
* This class handles taskana exceptions.
@ -52,8 +50,8 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
return buildResponse(ex, req, HttpStatus.FORBIDDEN);
}
@ExceptionHandler(TaskNotFoundException.class)
protected ResponseEntity<Object> handleTaskNotFound(TaskNotFoundException ex, WebRequest req) {
@ExceptionHandler(NotFoundException.class)
protected ResponseEntity<Object> handleTaskNotFound(NotFoundException ex, WebRequest req) {
return buildResponse(ex, req, HttpStatus.NOT_FOUND);
}
@ -79,12 +77,6 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
return buildResponse(ex, req, HttpStatus.CONFLICT);
}
@ExceptionHandler(ClassificationNotFoundException.class)
protected ResponseEntity<Object> handleClassificationNotFound(
ClassificationNotFoundException ex, WebRequest req) {
return buildResponse(ex, req, HttpStatus.NOT_FOUND);
}
@ExceptionHandler(ClassificationAlreadyExistException.class)
protected ResponseEntity<Object> handleClassificationAlreadyExist(
ClassificationAlreadyExistException ex, WebRequest req) {
@ -120,12 +112,6 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
return buildResponse(ex, req, HttpStatus.CONFLICT);
}
@ExceptionHandler(WorkbasketNotFoundException.class)
protected ResponseEntity<Object> handleWorkbasketNotFound(
WorkbasketNotFoundException ex, WebRequest req) {
return buildResponse(ex, req, HttpStatus.NOT_FOUND);
}
@ExceptionHandler(InvalidWorkbasketException.class)
protected ResponseEntity<Object> handleInvalidWorkbasket(
InvalidWorkbasketException ex, WebRequest req) {

View File

@ -53,7 +53,7 @@ class TaskCommentControllerIntTest {
new HttpEntity<String>(restHelper.getHeadersAdmin()),
ParameterizedTypeReference.forType(TaskCommentResource.class)))
.extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
.isEqualTo(HttpStatus.BAD_REQUEST);
.isEqualTo(HttpStatus.NOT_FOUND);
}
@Test