提交 42f033e4 编写于 作者: S Sam Brannen

Polish MockMvc internals regarding "effectively final"

上级 8b7ed5f4
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -172,7 +172,7 @@ public final class MockMvc {
request = ((SmartRequestBuilder) requestBuilder).postProcessRequest(request);
}
final MvcResult mvcResult = new DefaultMvcResult(request, mockResponse);
MvcResult mvcResult = new DefaultMvcResult(request, mockResponse);
request.setAttribute(MVC_RESULT_ATTRIBUTE, mvcResult);
RequestAttributes previousAttributes = RequestContextHolder.getRequestAttributes();
......
......@@ -91,7 +91,7 @@ final class TestDispatcherServlet extends DispatcherServlet {
}
}
private void registerAsyncResultInterceptors(final HttpServletRequest request) {
private void registerAsyncResultInterceptors(HttpServletRequest request) {
WebAsyncUtils.getAsyncManager(request).registerCallableInterceptor(KEY,
new CallableProcessingInterceptor() {
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.test.web.servlet.request;
import org.springframework.test.web.servlet.SmartRequestBuilder;
/**
* An extension of {@link org.springframework.test.web.servlet.SmartRequestBuilder
* SmartRequestBuilder} that can be configured with {@link RequestPostProcessor RequestPostProcessors}.
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -713,7 +713,7 @@ public class MockHttpServletRequestBuilder
}));
}
private MultiValueMap<String, String> parseFormData(final MediaType mediaType) {
private MultiValueMap<String, String> parseFormData(MediaType mediaType) {
HttpInputMessage message = new HttpInputMessage() {
@Override
public InputStream getBody() {
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -263,7 +263,7 @@ public abstract class MockMvcRequestBuilders {
* </pre>
* @param mvcResult the result from the request that started async processing
*/
public static RequestBuilder asyncDispatch(final MvcResult mvcResult) {
public static RequestBuilder asyncDispatch(MvcResult mvcResult) {
// There must be an async result before dispatching
mvcResult.getAsyncResult();
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -74,7 +74,7 @@ public class ContentResultMatchers {
* parameters. For checking only the type and sub-type see
* {@link #contentTypeCompatibleWith(MediaType)}.
*/
public ResultMatcher contentType(final MediaType contentType) {
public ResultMatcher contentType(MediaType contentType) {
return result -> {
String actual = result.getResponse().getContentType();
assertTrue("Content type not set", actual != null);
......@@ -96,7 +96,7 @@ public class ContentResultMatchers {
* Assert the ServletResponse content type is compatible with the given
* content type as defined by {@link MediaType#isCompatibleWith(MediaType)}.
*/
public ResultMatcher contentTypeCompatibleWith(final MediaType contentType) {
public ResultMatcher contentTypeCompatibleWith(MediaType contentType) {
return result -> {
String actual = result.getResponse().getContentType();
assertTrue("Content type not set", actual != null);
......@@ -112,7 +112,7 @@ public class ContentResultMatchers {
* Assert the character encoding in the ServletResponse.
* @see HttpServletResponse#getCharacterEncoding()
*/
public ResultMatcher encoding(final String characterEncoding) {
public ResultMatcher encoding(String characterEncoding) {
return result -> {
String actual = result.getResponse().getCharacterEncoding();
assertEquals("Character encoding", characterEncoding, actual);
......@@ -126,21 +126,21 @@ public class ContentResultMatchers {
* .andExpect(content().string(containsString("text")));
* </pre>
*/
public ResultMatcher string(final Matcher<? super String> matcher) {
public ResultMatcher string(Matcher<? super String> matcher) {
return result -> assertThat("Response content", result.getResponse().getContentAsString(), matcher);
}
/**
* Assert the response body content as a String.
*/
public ResultMatcher string(final String expectedContent) {
public ResultMatcher string(String expectedContent) {
return result -> assertEquals("Response content", expectedContent, result.getResponse().getContentAsString());
}
/**
* Assert the response body content as a byte array.
*/
public ResultMatcher bytes(final byte[] expectedContent) {
public ResultMatcher bytes(byte[] expectedContent) {
return result -> assertEquals("Response content", expectedContent, result.getResponse().getContentAsByteArray());
}
......@@ -154,7 +154,7 @@ public class ContentResultMatchers {
* @see MockMvcResultMatchers#xpath(String, Object...)
* @see MockMvcResultMatchers#xpath(String, Map, Object...)
*/
public ResultMatcher xml(final String xmlContent) {
public ResultMatcher xml(String xmlContent) {
return result -> {
String content = result.getResponse().getContentAsString();
this.xmlHelper.assertXmlEqual(xmlContent, content);
......@@ -165,7 +165,7 @@ public class ContentResultMatchers {
* Parse the response content as {@link Node} and apply the given Hamcrest
* {@link Matcher}.
*/
public ResultMatcher node(final Matcher<? super Node> matcher) {
public ResultMatcher node(Matcher<? super Node> matcher) {
return result -> {
String content = result.getResponse().getContentAsString();
this.xmlHelper.assertNode(content, matcher);
......@@ -177,7 +177,7 @@ public class ContentResultMatchers {
* Hamcrest {@link Matcher}.
* @see <a href="https://code.google.com/p/xml-matchers/">xml-matchers</a>
*/
public ResultMatcher source(final Matcher<? super Source> matcher) {
public ResultMatcher source(Matcher<? super Source> matcher) {
return result -> {
String content = result.getResponse().getContentAsString();
this.xmlHelper.assertSource(content, matcher);
......@@ -192,7 +192,7 @@ public class ContentResultMatchers {
* @param jsonContent the expected JSON content
* @since 4.1
*/
public ResultMatcher json(final String jsonContent) {
public ResultMatcher json(String jsonContent) {
return json(jsonContent, false);
}
......@@ -210,7 +210,7 @@ public class ContentResultMatchers {
* @param strict enables strict checking
* @since 4.2
*/
public ResultMatcher json(final String jsonContent, final boolean strict) {
public ResultMatcher json(String jsonContent, boolean strict) {
return result -> {
String content = result.getResponse().getContentAsString();
this.jsonHelper.assertJsonEqual(jsonContent, content, strict);
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -51,7 +51,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie value with the given Hamcrest {@link Matcher}.
*/
public ResultMatcher value(final String name, final Matcher<? super String> matcher) {
public ResultMatcher value(String name, Matcher<? super String> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "'", cookie.getValue(), matcher);
......@@ -61,7 +61,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie value.
*/
public ResultMatcher value(final String name, final String expectedValue) {
public ResultMatcher value(String name, String expectedValue) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie", expectedValue, cookie.getValue());
......@@ -72,7 +72,7 @@ public class CookieResultMatchers {
* Assert a cookie exists. The existence check is irrespective of whether
* max age is 0 (i.e. expired).
*/
public ResultMatcher exists(final String name) {
public ResultMatcher exists(String name) {
return result -> getCookie(result, name);
}
......@@ -80,7 +80,7 @@ public class CookieResultMatchers {
* Assert a cookie does not exist. Note that the existence check is
* irrespective of whether max age is 0, i.e. expired.
*/
public ResultMatcher doesNotExist(final String name) {
public ResultMatcher doesNotExist(String name) {
return result -> {
Cookie cookie = result.getResponse().getCookie(name);
assertTrue("Unexpected cookie with name '" + name + "'", cookie == null);
......@@ -90,7 +90,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's maxAge with a Hamcrest {@link Matcher}.
*/
public ResultMatcher maxAge(final String name, final Matcher<? super Integer> matcher) {
public ResultMatcher maxAge(String name, Matcher<? super Integer> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "' maxAge", cookie.getMaxAge(), matcher);
......@@ -100,7 +100,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's maxAge value.
*/
public ResultMatcher maxAge(final String name, final int maxAge) {
public ResultMatcher maxAge(String name, int maxAge) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' maxAge", maxAge, cookie.getMaxAge());
......@@ -110,14 +110,14 @@ public class CookieResultMatchers {
/**
* Assert a cookie path with a Hamcrest {@link Matcher}.
*/
public ResultMatcher path(final String name, final Matcher<? super String> matcher) {
public ResultMatcher path(String name, Matcher<? super String> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "' path", cookie.getPath(), matcher);
};
}
public ResultMatcher path(final String name, final String path) {
public ResultMatcher path(String name, String path) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' path", path, cookie.getPath());
......@@ -127,7 +127,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's domain with a Hamcrest {@link Matcher}.
*/
public ResultMatcher domain(final String name, final Matcher<? super String> matcher) {
public ResultMatcher domain(String name, Matcher<? super String> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "' domain", cookie.getDomain(), matcher);
......@@ -137,7 +137,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's domain value.
*/
public ResultMatcher domain(final String name, final String domain) {
public ResultMatcher domain(String name, String domain) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' domain", domain, cookie.getDomain());
......@@ -147,7 +147,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's comment with a Hamcrest {@link Matcher}.
*/
public ResultMatcher comment(final String name, final Matcher<? super String> matcher) {
public ResultMatcher comment(String name, Matcher<? super String> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "' comment", cookie.getComment(), matcher);
......@@ -157,7 +157,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's comment value.
*/
public ResultMatcher comment(final String name, final String comment) {
public ResultMatcher comment(String name, String comment) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' comment", comment, cookie.getComment());
......@@ -167,7 +167,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's version with a Hamcrest {@link Matcher}.
*/
public ResultMatcher version(final String name, final Matcher<? super Integer> matcher) {
public ResultMatcher version(String name, Matcher<? super Integer> matcher) {
return result -> {
Cookie cookie = getCookie(result, name);
assertThat("Response cookie '" + name + "' version", cookie.getVersion(), matcher);
......@@ -177,7 +177,7 @@ public class CookieResultMatchers {
/**
* Assert a cookie's version value.
*/
public ResultMatcher version(final String name, final int version) {
public ResultMatcher version(String name, int version) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' version", version, cookie.getVersion());
......@@ -187,7 +187,7 @@ public class CookieResultMatchers {
/**
* Assert whether the cookie must be sent over a secure protocol or not.
*/
public ResultMatcher secure(final String name, final boolean secure) {
public ResultMatcher secure(String name, boolean secure) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' secure", secure, cookie.getSecure());
......@@ -198,7 +198,7 @@ public class CookieResultMatchers {
* Assert whether the cookie must be HTTP only.
* @since 4.3.9
*/
public ResultMatcher httpOnly(final String name, final boolean httpOnly) {
public ResultMatcher httpOnly(String name, boolean httpOnly) {
return result -> {
Cookie cookie = getCookie(result, name);
assertEquals("Response cookie '" + name + "' httpOnly", httpOnly, cookie.isHttpOnly());
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -47,21 +47,21 @@ public class FlashAttributeResultMatchers {
* Assert a flash attribute's value with the given Hamcrest {@link Matcher}.
*/
@SuppressWarnings("unchecked")
public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
public <T> ResultMatcher attribute(String name, Matcher<T> matcher) {
return result -> assertThat("Flash attribute '" + name + "'", (T) result.getFlashMap().get(name), matcher);
}
/**
* Assert a flash attribute's value.
*/
public <T> ResultMatcher attribute(final String name, final Object value) {
public <T> 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 <T> ResultMatcher attributeExists(final String... names) {
public <T> ResultMatcher attributeExists(String... names) {
return result -> {
for (String name : names) {
assertTrue("Flash attribute '" + name + "' does not exist", result.getFlashMap().get(name) != null);
......@@ -72,7 +72,7 @@ public class FlashAttributeResultMatchers {
/**
* Assert the number of flash attributes.
*/
public <T> ResultMatcher attributeCount(final int count) {
public <T> ResultMatcher attributeCount(int count) {
return result -> assertEquals("FlashMap size must be " + count, count, result.getFlashMap().size());
}
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -62,7 +62,7 @@ public class HandlerResultMatchers {
/**
* Assert the type of the handler that processed the request.
*/
public ResultMatcher handlerType(final Class<?> type) {
public ResultMatcher handlerType(Class<?> type) {
return result -> {
Object handler = result.getHandler();
assertTrue("No handler", handler != null);
......@@ -100,7 +100,7 @@ public class HandlerResultMatchers {
* @param obj either the value returned from a "mock" controller invocation
* or the "mock" controller itself after an invocation
*/
public ResultMatcher methodCall(final Object obj) {
public ResultMatcher methodCall(Object obj) {
return result -> {
if (!(obj instanceof MethodInvocationInfo)) {
fail(String.format("The supplied object [%s] is not an instance of %s. " +
......@@ -118,7 +118,7 @@ public class HandlerResultMatchers {
* Assert the name of the controller method used to process the request
* using the given Hamcrest {@link Matcher}.
*/
public ResultMatcher methodName(final Matcher<? super String> matcher) {
public ResultMatcher methodName(Matcher<? super String> matcher) {
return result -> {
HandlerMethod handlerMethod = getHandlerMethod(result);
assertThat("Handler method", handlerMethod.getMethod().getName(), matcher);
......@@ -128,7 +128,7 @@ public class HandlerResultMatchers {
/**
* Assert the name of the controller method used to process the request.
*/
public ResultMatcher methodName(final String name) {
public ResultMatcher methodName(String name) {
return result -> {
HandlerMethod handlerMethod = getHandlerMethod(result);
assertEquals("Handler method", name, handlerMethod.getMethod().getName());
......@@ -138,7 +138,7 @@ public class HandlerResultMatchers {
/**
* Assert the controller method used to process the request.
*/
public ResultMatcher method(final Method method) {
public ResultMatcher method(Method method) {
return result -> {
HandlerMethod handlerMethod = getHandlerMethod(result);
assertEquals("Handler method", method, handlerMethod.getMethod());
......
......@@ -55,7 +55,7 @@ public class HeaderResultMatchers {
* Assert the primary value of the response header with the given Hamcrest
* String {@code Matcher}.
*/
public ResultMatcher string(final String name, final Matcher<? super String> matcher) {
public ResultMatcher string(String name, Matcher<? super String> matcher) {
return result -> assertThat("Response header '" + name + "'", result.getResponse().getHeader(name), matcher);
}
......@@ -64,7 +64,7 @@ public class HeaderResultMatchers {
* Iterable {@link Matcher}.
* @since 4.3
*/
public <T> ResultMatcher stringValues(final String name, final Matcher<Iterable<String>> matcher) {
public <T> ResultMatcher stringValues(String name, Matcher<Iterable<String>> matcher) {
return result -> {
List<String> values = result.getResponse().getHeaders(name);
assertThat("Response header '" + name + "'", values, matcher);
......@@ -74,7 +74,7 @@ public class HeaderResultMatchers {
/**
* Assert the primary value of the response header as a String value.
*/
public ResultMatcher string(final String name, final String value) {
public ResultMatcher string(String name, String value) {
return result -> assertEquals("Response header '" + name + "'", value, result.getResponse().getHeader(name));
}
......@@ -82,7 +82,7 @@ public class HeaderResultMatchers {
* Assert the values of the response header as String values.
* @since 4.3
*/
public ResultMatcher stringValues(final String name, final String... values) {
public ResultMatcher stringValues(String name, String... values) {
return result -> {
List<Object> actual = result.getResponse().getHeaderValues(name);
assertEquals("Response header '" + name + "'", Arrays.asList(values), actual);
......@@ -93,7 +93,7 @@ public class HeaderResultMatchers {
* Assert that the named response header exists.
* @since 5.0.3
*/
public ResultMatcher exists(final String name) {
public ResultMatcher exists(String name) {
return result -> assertTrue("Response should contain header '" + name + "'",
result.getResponse().containsHeader(name));
}
......@@ -102,7 +102,7 @@ public class HeaderResultMatchers {
* Assert that the named response header does not exist.
* @since 4.0
*/
public ResultMatcher doesNotExist(final String name) {
public ResultMatcher doesNotExist(String name) {
return result -> assertTrue("Response should not contain header '" + name + "'",
!result.getResponse().containsHeader(name));
}
......@@ -113,7 +113,7 @@ public class HeaderResultMatchers {
* {@link AssertionError} if the response does not contain the specified
* header, or if the supplied {@code value} does not match the primary value.
*/
public ResultMatcher longValue(final String name, final long value) {
public ResultMatcher longValue(String name, long value) {
return result -> {
MockHttpServletResponse response = result.getResponse();
assertTrue("Response does not contain header '" + name + "'", response.containsHeader(name));
......@@ -133,7 +133,7 @@ public class HeaderResultMatchers {
* @since 4.2
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
*/
public ResultMatcher dateValue(final String name, final long value) {
public ResultMatcher dateValue(String name, long value) {
return result -> {
MockHttpServletResponse response = result.getResponse();
String headerValue = response.getHeader(name);
......
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -97,7 +97,7 @@ public abstract class MockMvcResultHandlers {
*/
private static class PrintWriterPrintingResultHandler extends PrintingResultHandler {
public PrintWriterPrintingResultHandler(final PrintWriter writer) {
public PrintWriterPrintingResultHandler(PrintWriter writer) {
super(new ResultValuePrinter() {
@Override
public void printHeading(String heading) {
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -54,7 +54,7 @@ public class ModelResultMatchers {
* Assert a model attribute value with the given Hamcrest {@link Matcher}.
*/
@SuppressWarnings("unchecked")
public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
public <T> ResultMatcher attribute(String name, Matcher<T> matcher) {
return result -> {
ModelAndView mav = getModelAndView(result);
assertThat("Model attribute '" + name + "'", (T) mav.getModel().get(name), matcher);
......@@ -64,7 +64,7 @@ public class ModelResultMatchers {
/**
* Assert a model attribute value.
*/
public ResultMatcher attribute(final String name, final Object value) {
public ResultMatcher attribute(String name, Object value) {
return result -> {
ModelAndView mav = getModelAndView(result);
assertEquals("Model attribute '" + name + "'", value, mav.getModel().get(name));
......@@ -74,7 +74,7 @@ public class ModelResultMatchers {
/**
* Assert the given model attributes exist.
*/
public ResultMatcher attributeExists(final String... names) {
public ResultMatcher attributeExists(String... names) {
return result -> {
ModelAndView mav = getModelAndView(result);
for (String name : names) {
......@@ -86,7 +86,7 @@ public class ModelResultMatchers {
/**
* Assert the given model attributes do not exist.
*/
public ResultMatcher attributeDoesNotExist(final String... names) {
public ResultMatcher attributeDoesNotExist(String... names) {
return result -> {
ModelAndView mav = getModelAndView(result);
for (String name : names) {
......@@ -98,7 +98,7 @@ public class ModelResultMatchers {
/**
* Assert the given model attribute(s) have errors.
*/
public ResultMatcher attributeErrorCount(final String name, final int expectedCount) {
public ResultMatcher attributeErrorCount(String name, int expectedCount) {
return result -> {
ModelAndView mav = getModelAndView(result);
Errors errors = getBindingResult(mav, name);
......@@ -110,7 +110,7 @@ public class ModelResultMatchers {
/**
* Assert the given model attribute(s) have errors.
*/
public ResultMatcher attributeHasErrors(final String... names) {
public ResultMatcher attributeHasErrors(String... names) {
return mvcResult -> {
ModelAndView mav = getModelAndView(mvcResult);
for (String name : names) {
......@@ -123,7 +123,7 @@ public class ModelResultMatchers {
/**
* Assert the given model attribute(s) do not have errors.
*/
public ResultMatcher attributeHasNoErrors(final String... names) {
public ResultMatcher attributeHasNoErrors(String... names) {
return mvcResult -> {
ModelAndView mav = getModelAndView(mvcResult);
for (String name : names) {
......@@ -137,12 +137,12 @@ public class ModelResultMatchers {
/**
* Assert the given model attribute field(s) have errors.
*/
public ResultMatcher attributeHasFieldErrors(final String name, final String... fieldNames) {
public ResultMatcher attributeHasFieldErrors(String name, String... fieldNames) {
return mvcResult -> {
ModelAndView mav = getModelAndView(mvcResult);
BindingResult result = getBindingResult(mav, name);
assertTrue("No errors for attribute '" + name + "'", result.hasErrors());
for (final String fieldName : fieldNames) {
for (String fieldName : fieldNames) {
boolean hasFieldErrors = result.hasFieldErrors(fieldName);
assertTrue("No errors for field '" + fieldName + "' of attribute '" + name + "'", hasFieldErrors);
}
......@@ -153,7 +153,7 @@ public class ModelResultMatchers {
* Assert a field error code for a model attribute using exact String match.
* @since 4.1
*/
public ResultMatcher attributeHasFieldErrorCode(final String name, final String fieldName, final String error) {
public ResultMatcher attributeHasFieldErrorCode(String name, String fieldName, String error) {
return mvcResult -> {
ModelAndView mav = getModelAndView(mvcResult);
BindingResult result = getBindingResult(mav, name);
......@@ -171,8 +171,8 @@ public class ModelResultMatchers {
* Assert a field error code for a model attribute using a {@link org.hamcrest.Matcher}.
* @since 4.1
*/
public <T> ResultMatcher attributeHasFieldErrorCode(final String name, final String fieldName,
final Matcher<? super String> matcher) {
public <T> ResultMatcher attributeHasFieldErrorCode(String name, String fieldName,
Matcher<? super String> matcher) {
return mvcResult -> {
ModelAndView mav = getModelAndView(mvcResult);
......@@ -190,7 +190,7 @@ public class ModelResultMatchers {
/**
* Assert the total number of errors in the model.
*/
public <T> ResultMatcher errorCount(final int expectedCount) {
public <T> ResultMatcher errorCount(int expectedCount) {
return result -> {
int actualCount = getErrorCount(getModelAndView(result).getModelMap());
assertEquals("Binding/validation error count", expectedCount, actualCount);
......@@ -224,7 +224,7 @@ public class ModelResultMatchers {
/**
* Assert the number of model attributes.
*/
public <T> ResultMatcher size(final int size) {
public <T> ResultMatcher size(int size) {
return result -> {
ModelAndView mav = getModelAndView(result);
int actual = 0;
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -84,7 +84,7 @@ public class RequestResultMatchers {
* or {@link WebAsyncTask}.
*/
@SuppressWarnings("unchecked")
public <T> ResultMatcher asyncResult(final Matcher<T> matcher) {
public <T> ResultMatcher asyncResult(Matcher<T> matcher) {
return result -> {
HttpServletRequest request = result.getRequest();
assertAsyncStarted(request);
......@@ -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 <T> ResultMatcher asyncResult(final Object expectedResult) {
public <T> ResultMatcher asyncResult(Object expectedResult) {
return result -> {
HttpServletRequest request = result.getRequest();
assertAsyncStarted(request);
......@@ -110,7 +110,7 @@ public class RequestResultMatchers {
* Assert a request attribute value with the given Hamcrest {@link Matcher}.
*/
@SuppressWarnings("unchecked")
public <T> ResultMatcher attribute(final String name, final Matcher<T> matcher) {
public <T> ResultMatcher attribute(String name, Matcher<T> matcher) {
return result -> {
T value = (T) result.getRequest().getAttribute(name);
assertThat("Request attribute '" + name + "'", value, matcher);
......@@ -120,7 +120,7 @@ public class RequestResultMatchers {
/**
* Assert a request attribute value.
*/
public <T> ResultMatcher attribute(final String name, final Object expectedValue) {
public <T> ResultMatcher attribute(String name, Object expectedValue) {
return result ->
assertEquals("Request attribute '" + name + "'", expectedValue, result.getRequest().getAttribute(name));
}
......@@ -129,7 +129,7 @@ public class RequestResultMatchers {
* Assert a session attribute value with the given Hamcrest {@link Matcher}.
*/
@SuppressWarnings("unchecked")
public <T> ResultMatcher sessionAttribute(final String name, final Matcher<T> matcher) {
public <T> ResultMatcher sessionAttribute(String name, Matcher<T> matcher) {
return result -> {
HttpSession session = result.getRequest().getSession();
Assert.state(session != null, "No HttpSession");
......@@ -141,7 +141,7 @@ public class RequestResultMatchers {
/**
* Assert a session attribute value.
*/
public <T> ResultMatcher sessionAttribute(final String name, final Object value) {
public <T> ResultMatcher sessionAttribute(String name, Object value) {
return result -> {
HttpSession session = result.getRequest().getSession();
Assert.state(session != null, "No HttpSession");
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -51,7 +51,7 @@ public class StatusResultMatchers {
* Assert the response status code with the given Hamcrest {@link Matcher}.
* Use the {@code StatusResultMatchers.isEqualTo} extension in Kotlin.
*/
public ResultMatcher is(final Matcher<Integer> matcher) {
public ResultMatcher is(Matcher<Integer> matcher) {
return result -> assertThat("Response status", result.getResponse().getStatus(), matcher);
}
......@@ -59,7 +59,7 @@ public class StatusResultMatchers {
* Assert the response status code is equal to an integer value.
* Use the {@code StatusResultMatchers.isEqualTo} extension in Kotlin.
*/
public ResultMatcher is(final int status) {
public ResultMatcher is(int status) {
return result -> assertEquals("Response status", status, result.getResponse().getStatus());
}
......@@ -112,14 +112,14 @@ public class StatusResultMatchers {
/**
* Assert the Servlet response error message with the given Hamcrest {@link Matcher}.
*/
public ResultMatcher reason(final Matcher<? super String> matcher) {
public ResultMatcher reason(Matcher<? super String> matcher) {
return result -> assertThat("Response status reason", result.getResponse().getErrorMessage(), matcher);
}
/**
* Assert the Servlet response error message.
*/
public ResultMatcher reason(final String reason) {
public ResultMatcher reason(String reason) {
return result -> assertEquals("Response status reason", reason, result.getResponse().getErrorMessage());
}
......@@ -615,7 +615,7 @@ public class StatusResultMatchers {
/**
* Match the expected response status to that of the HttpServletResponse.
*/
private ResultMatcher matcher(final HttpStatus status) {
private ResultMatcher matcher(HttpStatus status) {
return result -> assertEquals("Status", status.value(), result.getResponse().getStatus());
}
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -47,7 +47,7 @@ public class ViewResultMatchers {
/**
* Assert the selected view name with the given Hamcrest {@link Matcher}.
*/
public ResultMatcher name(final Matcher<? super String> matcher) {
public ResultMatcher name(Matcher<? super String> matcher) {
return result -> {
ModelAndView mav = result.getModelAndView();
if (mav == null) {
......@@ -60,7 +60,7 @@ public class ViewResultMatchers {
/**
* Assert the selected view name.
*/
public ResultMatcher name(final String expectedViewName) {
public ResultMatcher name(String expectedViewName) {
return result -> {
ModelAndView mav = result.getModelAndView();
if (mav == null) {
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -61,7 +61,7 @@ public class XpathResultMatchers {
* Evaluate the XPath and assert the {@link Node} content found with the
* given Hamcrest {@link Matcher}.
*/
public ResultMatcher node(final Matcher<? super Node> matcher) {
public ResultMatcher node(Matcher<? super Node> matcher) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertNode(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
......@@ -100,7 +100,7 @@ public class XpathResultMatchers {
* Evaluate the XPath and assert the number of nodes found with the given
* Hamcrest {@link Matcher}.
*/
public ResultMatcher nodeCount(final Matcher<Integer> matcher) {
public ResultMatcher nodeCount(Matcher<Integer> matcher) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertNodeCount(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
......@@ -110,7 +110,7 @@ public class XpathResultMatchers {
/**
* Evaluate the XPath and assert the number of nodes found.
*/
public ResultMatcher nodeCount(final int expectedCount) {
public ResultMatcher nodeCount(int expectedCount) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertNodeCount(response.getContentAsByteArray(), getDefinedEncoding(response), expectedCount);
......@@ -121,7 +121,7 @@ public class XpathResultMatchers {
* Apply the XPath and assert the {@link String} value found with the given
* Hamcrest {@link Matcher}.
*/
public ResultMatcher string(final Matcher<? super String> matcher) {
public ResultMatcher string(Matcher<? super String> matcher) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertString(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
......@@ -131,7 +131,7 @@ public class XpathResultMatchers {
/**
* Apply the XPath and assert the {@link String} value found.
*/
public ResultMatcher string(final String expectedValue) {
public ResultMatcher string(String expectedValue) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertString(response.getContentAsByteArray(), getDefinedEncoding(response), expectedValue);
......@@ -142,7 +142,7 @@ public class XpathResultMatchers {
* Evaluate the XPath and assert the {@link Double} value found with the
* given Hamcrest {@link Matcher}.
*/
public ResultMatcher number(final Matcher<? super Double> matcher) {
public ResultMatcher number(Matcher<? super Double> matcher) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertNumber(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
......@@ -152,7 +152,7 @@ public class XpathResultMatchers {
/**
* Evaluate the XPath and assert the {@link Double} value found.
*/
public ResultMatcher number(final Double expectedValue) {
public ResultMatcher number(Double expectedValue) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertNumber(response.getContentAsByteArray(), getDefinedEncoding(response), expectedValue);
......@@ -162,7 +162,7 @@ public class XpathResultMatchers {
/**
* Evaluate the XPath and assert the {@link Boolean} value found.
*/
public ResultMatcher booleanValue(final Boolean value) {
public ResultMatcher booleanValue(Boolean value) {
return result -> {
MockHttpServletResponse response = result.getResponse();
this.xpathHelper.assertBoolean(response.getContentAsByteArray(), getDefinedEncoding(response), value);
......
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -546,7 +546,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
private final PlaceholderResolver resolver;
public StaticStringValueResolver(final Map<String, String> values) {
public StaticStringValueResolver(Map<String, String> values) {
this.helper = new PropertyPlaceholderHelper("${", "}", ":", false);
this.resolver = values::get;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册