Polish JsonContentTests

This commit is contained in:
Sam Brannen
2022-02-05 20:37:42 +01:00
parent 2ae6431a50
commit e077a753f8

View File

@@ -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();