diff --git a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java index f64b374dd1..e8c1b47522 100644 --- a/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/JsonPathExpectationsHelper.java @@ -69,7 +69,7 @@ public class JsonPathExpectationsHelper { * @param matcher the matcher with which to assert the result */ @SuppressWarnings("unchecked") - public void assertValue(String content, Matcher matcher) { + public void assertValue(String content, Matcher matcher) { T value = (T) evaluateJsonPath(content); MatcherAssert.assertThat("JSON path \"" + this.expression + "\"", value, matcher); } @@ -84,7 +84,7 @@ public class JsonPathExpectationsHelper { * @since 4.3.3 */ @SuppressWarnings("unchecked") - public void assertValue(String content, Matcher matcher, Class targetType) { + public void assertValue(String content, Matcher matcher, Class targetType) { T value = (T) evaluateJsonPath(content, targetType); MatcherAssert.assertThat("JSON path \"" + this.expression + "\"", value, matcher); } diff --git a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java index bea2c6d87f..19255b7365 100644 --- a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -138,7 +138,7 @@ public class XpathExpectationsHelper { * given Hamcrest matcher. * @throws Exception if content parsing or expression evaluation fails */ - public void assertNodeCount(byte[] content, @Nullable String encoding, Matcher matcher) + public void assertNodeCount(byte[] content, @Nullable String encoding, Matcher matcher) throws Exception { NodeList nodeList = evaluateXpath(content, encoding, NodeList.class); diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java index 78b2d21dbe..55050cdc9a 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/JsonPathRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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 JsonPathRequestMatchers { * Evaluate the JSON path expression against the request content and * assert the resulting value with the given Hamcrest {@link Matcher}. */ - public RequestMatcher value(Matcher matcher) { + public RequestMatcher value(Matcher matcher) { return new AbstractJsonPathRequestMatcher() { @Override protected void matchInternal(MockClientHttpRequest request) throws IOException, ParseException { @@ -78,7 +78,7 @@ public class JsonPathRequestMatchers { * to coerce an integer into a double. * @since 4.3.3 */ - public RequestMatcher value(Matcher matcher, Class targetType) { + public RequestMatcher value(Matcher matcher, Class targetType) { return new AbstractJsonPathRequestMatcher() { @Override protected void matchInternal(MockClientHttpRequest request) throws IOException, ParseException { diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java index 2f32065a90..ff3f6c27a7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/MockRestRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -73,7 +73,7 @@ public abstract class MockRestRequestMatchers { * @param matcher the String matcher for the expected URI * @return the request matcher */ - public static RequestMatcher requestTo(Matcher matcher) { + public static RequestMatcher requestTo(Matcher matcher) { Assert.notNull(matcher, "'matcher' must not be null"); return request -> assertThat("Request URI", request.getURI().toString(), matcher); } @@ -227,7 +227,7 @@ public abstract class MockRestRequestMatchers { * @param expression the JSON path expression * @param matcher a matcher for the value expected at the JSON path */ - public static RequestMatcher jsonPath(String expression, Matcher matcher) { + public static RequestMatcher jsonPath(String expression, Matcher matcher) { return new JsonPathRequestMatchers(expression).value(matcher); } diff --git a/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java b/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java index 6fd80b7d44..da90493f25 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/match/XpathRequestMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -93,7 +93,7 @@ public class XpathRequestMatchers { * Apply the XPath and assert the number of nodes found with the given * {@code Matcher}. */ - public RequestMatcher nodeCount(Matcher matcher) { + public RequestMatcher nodeCount(Matcher matcher) { return (XpathRequestMatcher) request -> this.xpathHelper.assertNodeCount(request.getBodyAsBytes(), DEFAULT_ENCODING, matcher); } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java index 2c3bff2494..98bf4361bc 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java @@ -422,13 +422,13 @@ class DefaultWebTestClient implements WebTestClient { } @Override - public T value(Matcher matcher) { + public T value(Matcher matcher) { this.result.assertWithDiagnostics(() -> MatcherAssert.assertThat(this.result.getResponseBody(), matcher)); return self(); } @Override - public T value(Function bodyMapper, Matcher matcher) { + public T value(Function bodyMapper, Matcher matcher) { this.result.assertWithDiagnostics(() -> { B body = this.result.getResponseBody(); MatcherAssert.assertThat(bodyMapper.apply(body), matcher); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java index 82813c6894..dfd8ce89c7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/HeaderAssertions.java @@ -160,7 +160,7 @@ public class HeaderAssertions { * @param matcher the matcher to use * @since 5.3 */ - public WebTestClient.ResponseSpec values(String name, Matcher> matcher) { + public WebTestClient.ResponseSpec values(String name, Matcher> matcher) { List values = getHeaders().get(name); this.exchangeResult.assertWithDiagnostics(() -> { String message = getMessage(name); diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java index 9dd9c518cf..c0c2d861fd 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -141,7 +141,7 @@ public class JsonPathAssertions { * Delegates to {@link JsonPathExpectationsHelper#assertValue(String, Matcher)}. * @since 5.1 */ - public WebTestClient.BodyContentSpec value(Matcher matcher) { + public WebTestClient.BodyContentSpec value(Matcher matcher) { this.pathHelper.assertValue(this.content, matcher); return this.bodySpec; } @@ -150,7 +150,7 @@ public class JsonPathAssertions { * Delegates to {@link JsonPathExpectationsHelper#assertValue(String, Matcher, Class)}. * @since 5.1 */ - public WebTestClient.BodyContentSpec value(Matcher matcher, Class targetType) { + public WebTestClient.BodyContentSpec value(Matcher matcher, Class targetType) { this.pathHelper.assertValue(this.content, matcher, targetType); return this.bodySpec; } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/StatusAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/StatusAssertions.java index 62d0a246f4..497b5bace1 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/StatusAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/StatusAssertions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -204,7 +204,7 @@ public class StatusAssertions { * @param matcher the matcher to use * @since 5.1 */ - public WebTestClient.ResponseSpec value(Matcher matcher) { + public WebTestClient.ResponseSpec value(Matcher matcher) { int value = this.exchangeResult.getStatus().value(); this.exchangeResult.assertWithDiagnostics(() -> MatcherAssert.assertThat("Response status", value, matcher)); return this.responseSpec; diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java index 4018ac1acd..f2436c80d3 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/WebTestClient.java @@ -838,14 +838,14 @@ public interface WebTestClient { * Assert the extracted body with a {@link Matcher}. * @since 5.1 */ - T value(Matcher matcher); + T value(Matcher matcher); /** * Transform the extracted the body with a function, e.g. extracting a * property, and assert the mapped value with a {@link Matcher}. * @since 5.1 */ - T value(Function bodyMapper, Matcher matcher); + T value(Function bodyMapper, Matcher matcher); /** * Assert the extracted body with a {@link Consumer}. diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java index b64497fedb..742aa2d43c 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -126,7 +126,7 @@ public class XpathAssertions { * Delegates to {@link XpathExpectationsHelper#assertNodeCount(byte[], String, Matcher)}. * @since 5.1 */ - public WebTestClient.BodyContentSpec nodeCount(Matcher matcher){ + public WebTestClient.BodyContentSpec nodeCount(Matcher matcher){ return assertWith(() -> this.xpathHelper.assertNodeCount(getContent(), getCharset(), matcher)); } 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 41512061dc..b403f1d1b1 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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 FlashAttributeResultMatchers { * Assert a flash attribute's value with the given Hamcrest {@link Matcher}. */ @SuppressWarnings("unchecked") - public ResultMatcher attribute(String name, Matcher matcher) { + public ResultMatcher attribute(String name, Matcher matcher) { return result -> assertThat("Flash attribute '" + name + "'", (T) result.getFlashMap().get(name), matcher); } 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 9a764a07e2..9abbfd0f86 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -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/JsonPathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java index 869e3200dc..f2f78967bc 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/JsonPathResultMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -83,7 +83,7 @@ public class JsonPathResultMatchers { * @see #value(Matcher, Class) * @see #value(Object) */ - public ResultMatcher value(Matcher matcher) { + public ResultMatcher value(Matcher matcher) { return result -> this.jsonPathHelper.assertValue(getContent(result), matcher); } @@ -97,7 +97,7 @@ public class JsonPathResultMatchers { * @see #value(Matcher) * @see #value(Object) */ - public ResultMatcher value(Matcher matcher, Class targetType) { + public ResultMatcher value(Matcher matcher, Class targetType) { return result -> this.jsonPathHelper.assertValue(getContent(result), matcher, targetType); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java index 2ad7fac08a..a3392535bb 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/MockMvcResultMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -206,7 +206,7 @@ public abstract class MockMvcResultMatchers { * @see #jsonPath(String, Object...) * @see #jsonPath(String, Matcher, Class) */ - public static ResultMatcher jsonPath(String expression, Matcher matcher) { + public static ResultMatcher jsonPath(String expression, Matcher matcher) { return new JsonPathResultMatchers(expression).value(matcher); } @@ -224,7 +224,7 @@ public abstract class MockMvcResultMatchers { * @see #jsonPath(String, Object...) * @see #jsonPath(String, Matcher) */ - public static ResultMatcher jsonPath(String expression, Matcher matcher, Class targetType) { + public static ResultMatcher jsonPath(String expression, Matcher matcher, Class targetType) { return new JsonPathResultMatchers(expression).value(matcher, targetType); } 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 b16712f3e5..00bf0626fe 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -57,7 +57,7 @@ public class ModelResultMatchers { * Assert a model attribute value with the given Hamcrest {@link Matcher}. */ @SuppressWarnings("unchecked") - public ResultMatcher attribute(String name, Matcher matcher) { + public ResultMatcher attribute(String name, Matcher matcher) { return result -> { ModelAndView mav = getModelAndView(result); assertThat("Model attribute '" + name + "'", (T) mav.getModel().get(name), matcher); 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 a92569e3a3..eb1c63bf5d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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 ResultMatcher asyncResult(Matcher matcher) { + public ResultMatcher asyncResult(Matcher matcher) { 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 ResultMatcher attribute(String name, Matcher matcher) { + public ResultMatcher attribute(String name, Matcher matcher) { return result -> { T value = (T) result.getRequest().getAttribute(name); assertThat("Request attribute '" + name + "'", value, matcher); @@ -129,7 +129,7 @@ public class RequestResultMatchers { * Assert a session attribute value with the given Hamcrest {@link Matcher}. */ @SuppressWarnings("unchecked") - public ResultMatcher sessionAttribute(String name, Matcher matcher) { + public ResultMatcher sessionAttribute(String name, Matcher matcher) { return result -> { HttpSession session = result.getRequest().getSession(); Assert.state(session != null, "No HttpSession"); diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java index 24a769ef88..a33eba0fa1 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/StatusResultMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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(Matcher matcher) { + public ResultMatcher is(Matcher matcher) { return result -> assertThat("Response status", result.getResponse().getStatus(), matcher); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java index e6025e1b3c..4528d2b40d 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -114,7 +114,7 @@ public class XpathResultMatchers { * Evaluate the XPath and assert the number of nodes found with the given * Hamcrest {@link Matcher}. */ - public ResultMatcher nodeCount(Matcher matcher) { + public ResultMatcher nodeCount(Matcher matcher) { return result -> { MockHttpServletResponse response = result.getResponse(); this.xpathHelper.assertNodeCount(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);