TSK-1822: fix error message for wrong order parameter

This commit is contained in:
ryzheboka 2022-03-22 12:06:18 +01:00 committed by Elena Mokeeva
parent 71f928972d
commit 70dfebb432
2 changed files with 21 additions and 1 deletions

View File

@ -222,7 +222,8 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
// value for the error output and want to use the contains performance boost of a HashSet.
List<String> enumConstants =
Arrays.stream(targetType.getEnumConstants())
.map(Object::toString)
.map(Enum.class::cast)
.map(Enum::name)
.collect(Collectors.toList());
Set<String> enumConstantSet = new HashSet<>(enumConstants);

View File

@ -1092,6 +1092,25 @@ class TaskControllerIntTest {
.isEqualTo(HttpStatus.BAD_REQUEST);
}
@Test
void should_ThrowException_When_ProvidingInvalidOrder() {
String url =
restHelper.toUrl(RestEndpoints.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001"
+ "&sort-by=NAME&order=WRONG";
HttpEntity<Object> auth = new HttpEntity<>(RestHelper.generateHeadersForUser("teamlead-1"));
ThrowingCallable httpCall =
() -> TEMPLATE.exchange(url, HttpMethod.GET, auth, TASK_SUMMARY_PAGE_MODEL_TYPE);
assertThatThrownBy(httpCall)
.isInstanceOf(HttpStatusCodeException.class)
.hasMessageContaining("\"expectedValues\":[\"ASCENDING\",\"DESCENDING\"]")
.extracting(HttpStatusCodeException.class::cast)
.extracting(HttpStatusCodeException::getStatusCode)
.isEqualTo(HttpStatus.BAD_REQUEST);
}
@TestFactory
Stream<DynamicTest> should_SetTransferFlagDependentOnRequestBody_When_TransferringTask() {
Iterator<Boolean> iterator = Arrays.asList(true, false).iterator();