diff --git a/src/main/java/io/cryostat/ExceptionMappers.java b/src/main/java/io/cryostat/ExceptionMappers.java index a1895beb1..f03dc89fd 100644 --- a/src/main/java/io/cryostat/ExceptionMappers.java +++ b/src/main/java/io/cryostat/ExceptionMappers.java @@ -48,4 +48,9 @@ public RestResponse mapScriptException(ScriptException ex) { public RestResponse mapNoSuchKeyException(NoSuchKeyException ex) { return RestResponse.status(HttpResponseStatus.NOT_FOUND.code()); } + + @ServerExceptionMapper + public RestResponse mapIllegalArgumentException(IllegalArgumentException exception) { + return RestResponse.status(HttpResponseStatus.BAD_REQUEST.code()); + } } diff --git a/src/test/java/itest/RulesPostJsonIT.java b/src/test/java/itest/RulesPostJsonIT.java index 003777bda..838ff1f6b 100644 --- a/src/test/java/itest/RulesPostJsonIT.java +++ b/src/test/java/itest/RulesPostJsonIT.java @@ -37,7 +37,6 @@ import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; @QuarkusIntegrationTest @TestMethodOrder(OrderAnnotation.class) @@ -107,12 +106,6 @@ void testAddRuleThrowsWhenMimeUnsupported() throws Exception { ex.getCause().getMessage(), Matchers.equalTo("Unsupported Media Type")); } - @DisabledIfEnvironmentVariable( - named = "CI", - matches = "true", - disabledReason = - "The server 500 seems to cause issues for the next test in the suite, ex. HTTP" - + " connection closed when attempting to POST the next rule definition") @Test @Order(3) void testAddRuleThrowsWhenMimeInvalid() throws Exception { @@ -131,9 +124,8 @@ void testAddRuleThrowsWhenMimeInvalid() throws Exception { Assertions.assertThrows( ExecutionException.class, () -> response.get(10, TimeUnit.SECONDS)); MatcherAssert.assertThat( - ((HttpException) ex.getCause()).getStatusCode(), Matchers.equalTo(500)); - MatcherAssert.assertThat( - ex.getCause().getMessage(), Matchers.equalTo("Internal Server Error")); + ((HttpException) ex.getCause()).getStatusCode(), Matchers.equalTo(400)); + MatcherAssert.assertThat(ex.getCause().getMessage(), Matchers.equalTo("Bad Request")); } @Test