mixitconf/mixit

unit test status code and body in one stream

Closed this issue · 1 comments

hi, I'm newer in kotlin and reactor
Can I test status code and body in one stream?

something like below or else?

   @Test
    fun home() {
        client.get().uri("/").accept(TEXT_HTML)
                .exchange()
                // map to status and body Flux
                .test()
                .expectNext(OK)
                .expectNext("some body")
                .verifyComplete()
    }
    @Test
    fun home() {
        client.get().uri("/").accept(TEXT_HTML)
                .exchange()
                .test()
                .consumeNextWith {
                      // test status code and body
                 }
                .verifyComplete()
    }

and in WebTestClient can do (Java)

client.post().uri("/user")
                .contentType(MediaType.APPLICATION_JSON)
                .body(Mono.just(user), User.class)
                .exchange()
                .expectStatus().isOk()
                .expectBody().jsonPath("name").isEqualTo("Test");

Thanks

please read more doc like manual. @fanliming