Fix wrong order of arguments in assertThat()

This commit is contained in:
Tom Hombergs
2020-06-21 18:55:31 +10:00
parent 0815698aff
commit 6c86c730c5
3 changed files with 6 additions and 7 deletions

0
spring-boot/spring-boot-testing/gradlew vendored Normal file → Executable file
View File

View File

@@ -88,9 +88,8 @@ class RegisterRestControllerTest {
UserResource expectedResponseBody = user;
String actualResponseBody = mvcResult.getResponse().getContentAsString();
assertThat(objectMapper.writeValueAsString(expectedResponseBody))
.isEqualToIgnoringWhitespace(actualResponseBody);
assertThat(actualResponseBody).isEqualToIgnoringWhitespace(
objectMapper.writeValueAsString(expectedResponseBody));
}
@Test
@@ -121,8 +120,8 @@ class RegisterRestControllerTest {
UserResource expected = user;
UserResource actualResponseBody = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), UserResource.class);
assertThat(expected.getName()).isEqualTo(actualResponseBody.getName());
assertThat(expected.getEmail()).isEqualTo(actualResponseBody.getEmail());
assertThat(actualResponseBody.getName()).isEqualTo(expected.getName());
assertThat(actualResponseBody.getEmail()).isEqualTo(expected.getEmail());
}
@@ -153,7 +152,7 @@ class RegisterRestControllerTest {
ErrorResult expectedErrorResponse = new ErrorResult("name", "must not be null");
String actualResponseBody = mvcResult.getResponse().getContentAsString();
String expectedResponseBody = objectMapper.writeValueAsString(expectedErrorResponse);
assertThat(expectedResponseBody).isEqualToIgnoringWhitespace(actualResponseBody);
assertThat(actualResponseBody).isEqualToIgnoringWhitespace(expectedResponseBody);
}
@Test

View File

@@ -16,7 +16,7 @@ public class ResponseBodyMatchers {
return mvcResult -> {
String json = mvcResult.getResponse().getContentAsString();
T actualObject = objectMapper.readValue(json, targetClass);
assertThat(expectedObject).isEqualToComparingFieldByField(actualObject);
assertThat(actualObject).isEqualToComparingFieldByField(expectedObject);
};
}