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): Send status code during exceptional future completion #585

Merged

Conversation

jan-law
Copy link
Contributor

@jan-law jan-law commented Jul 19, 2021

Related #474

When a CompleteableFuture is completed exceptionally, assertRequestStatus() will also send the HTTP status code along with the exception. Integration tests can now verify that the correct error code was returned along with the exception message.

e.g

webClient
                .post("/api/v2/rules")
                .sendForm(
                        testRule,
                        ar -> {
                            assertRequestStatus(ar, response);
                        });

        ExecutionException ex =
                Assertions.assertThrows(ExecutionException.class, () -> response.get());
        MatcherAssert.assertThat(
                ((HttpStatusException) ex.getCause()).getStatusCode(), Matchers.equalTo(400));
        MatcherAssert.assertThat(ex.getCause().getMessage(), Matchers.equalTo("Bad Request"));

Edit: I have also added status code checks to RulesPostJsonIT.java and RulesPostFormIT.java.

@jan-law jan-law requested a review from andrewazores July 19, 2021 20:37
andrewazores
andrewazores previously approved these changes Jul 19, 2021
@jan-law jan-law force-pushed the assert-status-code-with-request-status branch from f33519b to 2a8367c Compare July 19, 2021 20:46
@andrewazores andrewazores merged commit cccd17a into cryostatio:main Jul 19, 2021
@jan-law jan-law deleted the assert-status-code-with-request-status branch July 20, 2021 14:32
tthvo pushed a commit to tthvo/cryostat-legacy that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants