diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchers.java index 5e79c08216..41512061dc 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/FlashAttributeResultMatchers.java @@ -54,14 +54,14 @@ public class FlashAttributeResultMatchers { /** * Assert a flash attribute's value. */ - public ResultMatcher attribute(String name, Object value) { + public ResultMatcher attribute(String name, Object value) { return result -> assertEquals("Flash attribute '" + name + "'", value, result.getFlashMap().get(name)); } /** * Assert the existence of the given flash attributes. */ - public ResultMatcher attributeExists(String... names) { + public ResultMatcher attributeExists(String... names) { return result -> { for (String name : names) { assertNotNull("Flash attribute '" + name + "' does not exist", result.getFlashMap().get(name)); @@ -72,7 +72,7 @@ public class FlashAttributeResultMatchers { /** * Assert the number of flash attributes. */ - public ResultMatcher attributeCount(int count) { + public ResultMatcher attributeCount(int count) { return result -> assertEquals("FlashMap size", count, result.getFlashMap().size()); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/HeaderResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/HeaderResultMatchers.java index 60203db6d4..9a764a07e2 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/HeaderResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/HeaderResultMatchers.java @@ -65,7 +65,7 @@ public class HeaderResultMatchers { * Iterable {@link Matcher}. * @since 4.3 */ - public ResultMatcher stringValues(String name, Matcher> matcher) { + public ResultMatcher stringValues(String name, Matcher> matcher) { return result -> { List values = result.getResponse().getHeaders(name); assertThat("Response header '" + name + "'", values, matcher); diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/ModelResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/ModelResultMatchers.java index 507fd7b87b..b16712f3e5 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/ModelResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/ModelResultMatchers.java @@ -172,7 +172,7 @@ public class ModelResultMatchers { * Assert a field error code for a model attribute using a {@link org.hamcrest.Matcher}. * @since 4.1 */ - public ResultMatcher attributeHasFieldErrorCode(String name, String fieldName, + public ResultMatcher attributeHasFieldErrorCode(String name, String fieldName, Matcher matcher) { return mvcResult -> { @@ -189,7 +189,7 @@ public class ModelResultMatchers { /** * Assert the total number of errors in the model. */ - public ResultMatcher errorCount(int expectedCount) { + public ResultMatcher errorCount(int expectedCount) { return result -> { int actualCount = getErrorCount(getModelAndView(result).getModelMap()); assertEquals("Binding/validation error count", expectedCount, actualCount); @@ -199,7 +199,7 @@ public class ModelResultMatchers { /** * Assert the model has errors. */ - public ResultMatcher hasErrors() { + public ResultMatcher hasErrors() { return result -> { int count = getErrorCount(getModelAndView(result).getModelMap()); assertTrue("Expected binding/validation errors", count != 0); @@ -209,7 +209,7 @@ public class ModelResultMatchers { /** * Assert the model has no errors. */ - public ResultMatcher hasNoErrors() { + public ResultMatcher hasNoErrors() { return result -> { ModelAndView mav = getModelAndView(result); for (Object value : mav.getModel().values()) { @@ -223,7 +223,7 @@ public class ModelResultMatchers { /** * Assert the number of model attributes. */ - public ResultMatcher size(int size) { + public ResultMatcher size(int size) { return result -> { ModelAndView mav = getModelAndView(result); int actual = 0; diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java index 55f317c7a0..a92569e3a3 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/RequestResultMatchers.java @@ -98,7 +98,7 @@ public class RequestResultMatchers { * or {@link WebAsyncTask}. The value matched is the value returned from the * {@code Callable} or the exception raised. */ - public ResultMatcher asyncResult(Object expectedResult) { + public ResultMatcher asyncResult(Object expectedResult) { return result -> { HttpServletRequest request = result.getRequest(); assertAsyncStarted(request); @@ -120,7 +120,7 @@ public class RequestResultMatchers { /** * Assert a request attribute value. */ - public ResultMatcher attribute(String name, Object expectedValue) { + public ResultMatcher attribute(String name, Object expectedValue) { return result -> assertEquals("Request attribute '" + name + "'", expectedValue, result.getRequest().getAttribute(name)); } @@ -141,7 +141,7 @@ public class RequestResultMatchers { /** * Assert a session attribute value. */ - public ResultMatcher sessionAttribute(String name, Object value) { + public ResultMatcher sessionAttribute(String name, Object value) { return result -> { HttpSession session = result.getRequest().getSession(); Assert.state(session != null, "No HttpSession"); diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt index 98dfa3effb..2ac5accb3a 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt @@ -130,7 +130,7 @@ class MockMvcExtensionsTests { assertThatExceptionOfType(AssertionError::class.java).isThrownBy { content { json("""{"name":"wrong"}""") } } assertThatExceptionOfType(AssertionError::class.java).isThrownBy { jsonPath("name") { value("wrong") } } assertThatExceptionOfType(AssertionError::class.java).isThrownBy { cookie { value("name", "wrong") } } - assertThatExceptionOfType(AssertionError::class.java).isThrownBy { flash { attribute("name", "wrong") } } + assertThatExceptionOfType(AssertionError::class.java).isThrownBy { flash { attribute("name", "wrong") } } assertThatExceptionOfType(AssertionError::class.java).isThrownBy { header { stringValues("name", "wrong") } } assertThatExceptionOfType(AssertionError::class.java).isThrownBy { model { attributeExists("name", "wrong") } } assertThatExceptionOfType(AssertionError::class.java).isThrownBy { redirectedUrl("wrong/Url") }