Fix wrong order of arguments in assertThat()
This commit is contained in:
0
spring-boot/spring-boot-testing/gradlew
vendored
Normal file → Executable file
0
spring-boot/spring-boot-testing/gradlew
vendored
Normal file → Executable file
@@ -88,9 +88,8 @@ class RegisterRestControllerTest {
|
|||||||
|
|
||||||
UserResource expectedResponseBody = user;
|
UserResource expectedResponseBody = user;
|
||||||
String actualResponseBody = mvcResult.getResponse().getContentAsString();
|
String actualResponseBody = mvcResult.getResponse().getContentAsString();
|
||||||
assertThat(objectMapper.writeValueAsString(expectedResponseBody))
|
assertThat(actualResponseBody).isEqualToIgnoringWhitespace(
|
||||||
.isEqualToIgnoringWhitespace(actualResponseBody);
|
objectMapper.writeValueAsString(expectedResponseBody));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -121,8 +120,8 @@ class RegisterRestControllerTest {
|
|||||||
|
|
||||||
UserResource expected = user;
|
UserResource expected = user;
|
||||||
UserResource actualResponseBody = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), UserResource.class);
|
UserResource actualResponseBody = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), UserResource.class);
|
||||||
assertThat(expected.getName()).isEqualTo(actualResponseBody.getName());
|
assertThat(actualResponseBody.getName()).isEqualTo(expected.getName());
|
||||||
assertThat(expected.getEmail()).isEqualTo(actualResponseBody.getEmail());
|
assertThat(actualResponseBody.getEmail()).isEqualTo(expected.getEmail());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +152,7 @@ class RegisterRestControllerTest {
|
|||||||
ErrorResult expectedErrorResponse = new ErrorResult("name", "must not be null");
|
ErrorResult expectedErrorResponse = new ErrorResult("name", "must not be null");
|
||||||
String actualResponseBody = mvcResult.getResponse().getContentAsString();
|
String actualResponseBody = mvcResult.getResponse().getContentAsString();
|
||||||
String expectedResponseBody = objectMapper.writeValueAsString(expectedErrorResponse);
|
String expectedResponseBody = objectMapper.writeValueAsString(expectedErrorResponse);
|
||||||
assertThat(expectedResponseBody).isEqualToIgnoringWhitespace(actualResponseBody);
|
assertThat(actualResponseBody).isEqualToIgnoringWhitespace(expectedResponseBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ResponseBodyMatchers {
|
|||||||
return mvcResult -> {
|
return mvcResult -> {
|
||||||
String json = mvcResult.getResponse().getContentAsString();
|
String json = mvcResult.getResponse().getContentAsString();
|
||||||
T actualObject = objectMapper.readValue(json, targetClass);
|
T actualObject = objectMapper.readValue(json, targetClass);
|
||||||
assertThat(expectedObject).isEqualToComparingFieldByField(actualObject);
|
assertThat(actualObject).isEqualToComparingFieldByField(expectedObject);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user