Spring:WebTestClient
Aus Alexander's Wiki
Version vom 20. Oktober 2022, 12:54 Uhr von Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<syntaxhighlight lang="java"> @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class ...Test { @Test void ...() {…“)
@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();
}
}