Spring:WebTestClient

Aus Alexander's Wiki
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ...Test {
    
    @Test
    void ...()
    {
        WebTestClient.ResponseSpec response = webTestClient
                .get()
                .uri("uri/protocol/openid-connect/certs")
                .header(ACCEPT, APPLICATION_JSON_VALUE)
                .exchange();

        response.expectStatus()
                .is2xxSuccessful()
                .expectHeader()
                .contentType(APPLICATION_JSON)
                .expectBody()
                .jsonPath("$.length()").isEqualTo(3)
                .jsonPath("$[0].id").isEqualTo(1)
                .jsonPath("$[0].name").isEqualTo("duke")
                .jsonPath("$[0].tags").isNotEmpty();

    }
    
}