Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(itest): overwrite the IllegalArgumentException http code #174

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/io/cryostat/ExceptionMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ public RestResponse<Void> mapScriptException(ScriptException ex) {
public RestResponse<Void> mapNoSuchKeyException(NoSuchKeyException ex) {
return RestResponse.status(HttpResponseStatus.NOT_FOUND.code());
}

@ServerExceptionMapper
public RestResponse<Void> mapIllegalArgumentException(IllegalArgumentException exception) {
return RestResponse.status(HttpResponseStatus.BAD_REQUEST.code());
}
}
12 changes: 2 additions & 10 deletions src/test/java/itest/RulesPostJsonIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading