diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index a629ce1fee4..2b41115f6a5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -236,6 +236,7 @@ abstract class AbstractPropertyAccessorTests { } @Test + @SuppressWarnings("unchecked") void getPropertyIntermediateMapEntryIsNullWithAutoGrow() { Foo target = new Foo(); AbstractPropertyAccessor accessor = createAccessor(target); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java index c91fac8d99f..25739ac772a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java @@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; public class ManagedPropertiesTests { @Test + @SuppressWarnings("unchecked") public void mergeSunnyDay() { ManagedProperties parent = new ManagedProperties(); parent.setProperty("one", "one"); @@ -67,6 +68,7 @@ public class ManagedPropertiesTests { } @Test + @SuppressWarnings("unchecked") public void mergeEmptyChild() { ManagedProperties parent = new ManagedProperties(); parent.setProperty("one", "one"); @@ -78,6 +80,7 @@ public class ManagedPropertiesTests { } @Test + @SuppressWarnings("unchecked") public void mergeChildValuesOverrideTheParents() { ManagedProperties parent = new ManagedProperties(); parent.setProperty("one", "one"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java index c50cbd5fe4f..ac739a1b76d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java @@ -53,7 +53,7 @@ public class CollectionMergingTests { @Test public void mergeList() throws Exception { TestBean bean = (TestBean) this.beanFactory.getBean("childWithList"); - List list = bean.getSomeList(); + List list = bean.getSomeList(); assertThat(list).as("Incorrect size").hasSize(3); assertThat(list.get(0)).isEqualTo("Rob Harrop"); assertThat(list.get(1)).isEqualTo("Rod Johnson"); @@ -66,15 +66,13 @@ public class CollectionMergingTests { List list = bean.getSomeList(); assertThat(list).isNotNull(); assertThat(list).hasSize(3); - assertThat(list.get(2)).isNotNull(); - boolean condition = list.get(2) instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(list.get(2) instanceof TestBean).isTrue(); } @Test public void mergeSet() { TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet"); - Set set = bean.getSomeSet(); + Set set = bean.getSomeSet(); assertThat(set).as("Incorrect size").hasSize(2); assertThat(set.contains("Rob Harrop")).isTrue(); assertThat(set.contains("Sally Greenwood")).isTrue(); @@ -89,16 +87,14 @@ public class CollectionMergingTests { Iterator it = set.iterator(); it.next(); Object o = it.next(); - assertThat(o).isNotNull(); - boolean condition = o instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(o instanceof TestBean).isTrue(); assertThat(((TestBean) o).getName()).isEqualTo("Sally"); } @Test public void mergeMap() throws Exception { TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap"); - Map map = bean.getSomeMap(); + Map map = bean.getSomeMap(); assertThat(map).as("Incorrect size").hasSize(3); assertThat(map.get("Rob")).isEqualTo("Sally"); assertThat(map.get("Rod")).isEqualTo("Kerry"); @@ -112,8 +108,7 @@ public class CollectionMergingTests { assertThat(map).isNotNull(); assertThat(map).hasSize(2); assertThat(map.get("Rob")).isNotNull(); - boolean condition = map.get("Rob") instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(map.get("Rob") instanceof TestBean).isTrue(); assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally"); } @@ -130,7 +125,7 @@ public class CollectionMergingTests { @Test public void mergeListInConstructor() throws Exception { TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor"); - List list = bean.getSomeList(); + List list = bean.getSomeList(); assertThat(list).as("Incorrect size").hasSize(3); assertThat(list.get(0)).isEqualTo("Rob Harrop"); assertThat(list.get(1)).isEqualTo("Rod Johnson"); @@ -144,14 +139,13 @@ public class CollectionMergingTests { assertThat(list).isNotNull(); assertThat(list).hasSize(3); assertThat(list.get(2)).isNotNull(); - boolean condition = list.get(2) instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(list.get(2) instanceof TestBean).isTrue(); } @Test public void mergeSetInConstructor() { TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor"); - Set set = bean.getSomeSet(); + Set set = bean.getSomeSet(); assertThat(set).as("Incorrect size").hasSize(2); assertThat(set.contains("Rob Harrop")).isTrue(); assertThat(set.contains("Sally Greenwood")).isTrue(); @@ -166,16 +160,14 @@ public class CollectionMergingTests { Iterator it = set.iterator(); it.next(); Object o = it.next(); - assertThat(o).isNotNull(); - boolean condition = o instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(o instanceof TestBean).isTrue(); assertThat(((TestBean) o).getName()).isEqualTo("Sally"); } @Test public void mergeMapInConstructor() throws Exception { TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor"); - Map map = bean.getSomeMap(); + Map map = bean.getSomeMap(); assertThat(map).as("Incorrect size").hasSize(3); assertThat(map.get("Rob")).isEqualTo("Sally"); assertThat(map.get("Rod")).isEqualTo("Kerry"); @@ -188,9 +180,7 @@ public class CollectionMergingTests { Map map = bean.getSomeMap(); assertThat(map).isNotNull(); assertThat(map).hasSize(2); - assertThat(map.get("Rob")).isNotNull(); - boolean condition = map.get("Rob") instanceof TestBean; - assertThat(condition).isTrue(); + assertThat(map.get("Rob") instanceof TestBean).isTrue(); assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally"); } diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java index 58f78a86517..9594f24c674 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -505,7 +505,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) public void resolveOptionalParamValue() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultConversionService()); @@ -522,7 +522,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) public void missingOptionalParamValue() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultConversionService()); @@ -555,7 +555,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) public void missingOptionalParamArray() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultConversionService()); @@ -571,7 +571,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) public void resolveOptionalParamList() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultConversionService()); @@ -588,7 +588,7 @@ public class RequestParamMethodArgumentResolverTests { } @Test - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) public void missingOptionalParamList() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setConversionService(new DefaultConversionService()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index b4dda81d28d..ff9e1f1e04f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -375,7 +375,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(response.getContentAsString()).isEmpty(); } - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) @PathPatternsParameterizedTest void sessionAttributeExposure(boolean usePathPatterns) throws Exception { initDispatcherServlet( @@ -405,7 +405,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(((Map) session.getAttribute("model"))).containsKey("object2"); } - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) @PathPatternsParameterizedTest void sessionAttributeExposureWithInterface(boolean usePathPatterns) throws Exception { initDispatcherServlet(MySessionAttributesControllerImpl.class, usePathPatterns, wac -> { @@ -438,7 +438,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(((Map) session.getAttribute("model"))).containsKey("object2"); } - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) @PathPatternsParameterizedTest void parameterizedAnnotatedInterface(boolean usePathPatterns) throws Exception { initDispatcherServlet( @@ -470,7 +470,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList"); } - @SuppressWarnings("rawtypes") + @SuppressWarnings({ "rawtypes", "unchecked" }) @PathPatternsParameterizedTest void parameterizedAnnotatedInterfaceWithOverriddenMappingsInImpl(boolean usePathPatterns) throws Exception { initDispatcherServlet(