Suppress warnings in tests

This commit is contained in:
Sam Brannen 2023-04-07 14:23:55 +02:00
parent c811428512
commit 01fabfe66d
5 changed files with 25 additions and 31 deletions

View File

@ -236,6 +236,7 @@ abstract class AbstractPropertyAccessorTests {
}
@Test
@SuppressWarnings("unchecked")
void getPropertyIntermediateMapEntryIsNullWithAutoGrow() {
Foo target = new Foo();
AbstractPropertyAccessor accessor = createAccessor(target);

View File

@ -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");

View File

@ -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");
}

View File

@ -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());

View File

@ -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(