diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java index e6a4ed7799..31d8efd369 100644 --- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/JsonContentTests.java @@ -52,10 +52,13 @@ class JsonContentTests { .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk() - .expectBody().json( - "[{\"firstName\":\"Jane\"}," + - "{\"firstName\":\"Jason\"}," + - "{\"firstName\":\"John\"}]"); + .expectBody().json(""" + [ + {"firstName":"Jane"}, + {"firstName":"Jason"}, + {"firstName":"John"} + ] + """); } @Test @@ -64,10 +67,13 @@ class JsonContentTests { .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk() - .expectBody().json( - "[{\"firstName\":\"Jane\",\"lastName\":\"Williams\"}," + - "{\"firstName\":\"Jason\",\"lastName\":\"Johnson\"}," + - "{\"firstName\":\"John\",\"lastName\":\"Smith\"}]", + .expectBody().json(""" + [ + {"firstName":"Jane", "lastName":"Williams"}, + {"firstName":"Jason","lastName":"Johnson"}, + {"firstName":"John", "lastName":"Smith"} + ] + """, true); } @@ -76,10 +82,13 @@ class JsonContentTests { assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> this.client.get().uri("/persons") .accept(MediaType.APPLICATION_JSON) .exchange() - .expectBody().json( - "[{\"firstName\":\"Jane\"}," + - "{\"firstName\":\"Jason\"}," + - "{\"firstName\":\"John\"}]", + .expectBody().json(""" + [ + {"firstName":"Jane"}, + {"firstName":"Jason"}, + {"firstName":"John"} + ] + """, true) ); } @@ -110,7 +119,9 @@ class JsonContentTests { void postJsonContent() { this.client.post().uri("/persons") .contentType(MediaType.APPLICATION_JSON) - .bodyValue("{\"firstName\":\"John\",\"lastName\":\"Smith\"}") + .bodyValue(""" + {"firstName":"John", "lastName":"Smith"} + """) .exchange() .expectStatus().isCreated() .expectBody().isEmpty();