Skip to content

Commit 01fabfe

Browse files
committed
Suppress warnings in tests
1 parent c811428 commit 01fabfe

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void getPropertyIntermediatePropertyIsNullWithAutoGrow() {
236236
}
237237

238238
@Test
239+
@SuppressWarnings("unchecked")
239240
void getPropertyIntermediateMapEntryIsNullWithAutoGrow() {
240241
Foo target = new Foo();
241242
AbstractPropertyAccessor accessor = createAccessor(target);

spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
public class ManagedPropertiesTests {
3434

3535
@Test
36+
@SuppressWarnings("unchecked")
3637
public void mergeSunnyDay() {
3738
ManagedProperties parent = new ManagedProperties();
3839
parent.setProperty("one", "one");
@@ -67,6 +68,7 @@ public void mergeNotAllowedWhenMergeNotEnabled() {
6768
}
6869

6970
@Test
71+
@SuppressWarnings("unchecked")
7072
public void mergeEmptyChild() {
7173
ManagedProperties parent = new ManagedProperties();
7274
parent.setProperty("one", "one");
@@ -78,6 +80,7 @@ public void mergeEmptyChild() {
7880
}
7981

8082
@Test
83+
@SuppressWarnings("unchecked")
8184
public void mergeChildValuesOverrideTheParents() {
8285
ManagedProperties parent = new ManagedProperties();
8386
parent.setProperty("one", "one");

spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void setUp() throws Exception {
5353
@Test
5454
public void mergeList() throws Exception {
5555
TestBean bean = (TestBean) this.beanFactory.getBean("childWithList");
56-
List list = bean.getSomeList();
56+
List<?> list = bean.getSomeList();
5757
assertThat(list).as("Incorrect size").hasSize(3);
5858
assertThat(list.get(0)).isEqualTo("Rob Harrop");
5959
assertThat(list.get(1)).isEqualTo("Rod Johnson");
@@ -66,15 +66,13 @@ public void mergeListWithInnerBeanAsListElement() throws Exception {
6666
List<?> list = bean.getSomeList();
6767
assertThat(list).isNotNull();
6868
assertThat(list).hasSize(3);
69-
assertThat(list.get(2)).isNotNull();
70-
boolean condition = list.get(2) instanceof TestBean;
71-
assertThat(condition).isTrue();
69+
assertThat(list.get(2) instanceof TestBean).isTrue();
7270
}
7371

7472
@Test
7573
public void mergeSet() {
7674
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSet");
77-
Set set = bean.getSomeSet();
75+
Set<?> set = bean.getSomeSet();
7876
assertThat(set).as("Incorrect size").hasSize(2);
7977
assertThat(set.contains("Rob Harrop")).isTrue();
8078
assertThat(set.contains("Sally Greenwood")).isTrue();
@@ -89,16 +87,14 @@ public void mergeSetWithInnerBeanAsSetElement() throws Exception {
8987
Iterator it = set.iterator();
9088
it.next();
9189
Object o = it.next();
92-
assertThat(o).isNotNull();
93-
boolean condition = o instanceof TestBean;
94-
assertThat(condition).isTrue();
90+
assertThat(o instanceof TestBean).isTrue();
9591
assertThat(((TestBean) o).getName()).isEqualTo("Sally");
9692
}
9793

9894
@Test
9995
public void mergeMap() throws Exception {
10096
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMap");
101-
Map map = bean.getSomeMap();
97+
Map<?, ?> map = bean.getSomeMap();
10298
assertThat(map).as("Incorrect size").hasSize(3);
10399
assertThat(map.get("Rob")).isEqualTo("Sally");
104100
assertThat(map.get("Rod")).isEqualTo("Kerry");
@@ -112,8 +108,7 @@ public void mergeMapWithInnerBeanAsMapEntryValue() throws Exception {
112108
assertThat(map).isNotNull();
113109
assertThat(map).hasSize(2);
114110
assertThat(map.get("Rob")).isNotNull();
115-
boolean condition = map.get("Rob") instanceof TestBean;
116-
assertThat(condition).isTrue();
111+
assertThat(map.get("Rob") instanceof TestBean).isTrue();
117112
assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally");
118113
}
119114

@@ -130,7 +125,7 @@ public void mergeProperties() throws Exception {
130125
@Test
131126
public void mergeListInConstructor() throws Exception {
132127
TestBean bean = (TestBean) this.beanFactory.getBean("childWithListInConstructor");
133-
List list = bean.getSomeList();
128+
List<?> list = bean.getSomeList();
134129
assertThat(list).as("Incorrect size").hasSize(3);
135130
assertThat(list.get(0)).isEqualTo("Rob Harrop");
136131
assertThat(list.get(1)).isEqualTo("Rod Johnson");
@@ -144,14 +139,13 @@ public void mergeListWithInnerBeanAsListElementInConstructor() throws Exception
144139
assertThat(list).isNotNull();
145140
assertThat(list).hasSize(3);
146141
assertThat(list.get(2)).isNotNull();
147-
boolean condition = list.get(2) instanceof TestBean;
148-
assertThat(condition).isTrue();
142+
assertThat(list.get(2) instanceof TestBean).isTrue();
149143
}
150144

151145
@Test
152146
public void mergeSetInConstructor() {
153147
TestBean bean = (TestBean) this.beanFactory.getBean("childWithSetInConstructor");
154-
Set set = bean.getSomeSet();
148+
Set<?> set = bean.getSomeSet();
155149
assertThat(set).as("Incorrect size").hasSize(2);
156150
assertThat(set.contains("Rob Harrop")).isTrue();
157151
assertThat(set.contains("Sally Greenwood")).isTrue();
@@ -166,16 +160,14 @@ public void mergeSetWithInnerBeanAsSetElementInConstructor() throws Exception {
166160
Iterator it = set.iterator();
167161
it.next();
168162
Object o = it.next();
169-
assertThat(o).isNotNull();
170-
boolean condition = o instanceof TestBean;
171-
assertThat(condition).isTrue();
163+
assertThat(o instanceof TestBean).isTrue();
172164
assertThat(((TestBean) o).getName()).isEqualTo("Sally");
173165
}
174166

175167
@Test
176168
public void mergeMapInConstructor() throws Exception {
177169
TestBean bean = (TestBean) this.beanFactory.getBean("childWithMapInConstructor");
178-
Map map = bean.getSomeMap();
170+
Map<?, ?> map = bean.getSomeMap();
179171
assertThat(map).as("Incorrect size").hasSize(3);
180172
assertThat(map.get("Rob")).isEqualTo("Sally");
181173
assertThat(map.get("Rod")).isEqualTo("Kerry");
@@ -188,9 +180,7 @@ public void mergeMapWithInnerBeanAsMapEntryValueInConstructor() throws Exception
188180
Map<?, ?> map = bean.getSomeMap();
189181
assertThat(map).isNotNull();
190182
assertThat(map).hasSize(2);
191-
assertThat(map.get("Rob")).isNotNull();
192-
boolean condition = map.get("Rob") instanceof TestBean;
193-
assertThat(condition).isTrue();
183+
assertThat(map.get("Rob") instanceof TestBean).isTrue();
194184
assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally");
195185
}
196186

spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public void resolveEmptyValueRequiredWithoutDefault() throws Exception {
505505
}
506506

507507
@Test
508-
@SuppressWarnings("rawtypes")
508+
@SuppressWarnings({ "rawtypes", "unchecked" })
509509
public void resolveOptionalParamValue() throws Exception {
510510
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
511511
initializer.setConversionService(new DefaultConversionService());
@@ -522,7 +522,7 @@ public void resolveOptionalParamValue() throws Exception {
522522
}
523523

524524
@Test
525-
@SuppressWarnings("rawtypes")
525+
@SuppressWarnings({ "rawtypes", "unchecked" })
526526
public void missingOptionalParamValue() throws Exception {
527527
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
528528
initializer.setConversionService(new DefaultConversionService());
@@ -555,7 +555,7 @@ public void resolveOptionalParamArray() throws Exception {
555555
}
556556

557557
@Test
558-
@SuppressWarnings("rawtypes")
558+
@SuppressWarnings({ "rawtypes", "unchecked" })
559559
public void missingOptionalParamArray() throws Exception {
560560
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
561561
initializer.setConversionService(new DefaultConversionService());
@@ -571,7 +571,7 @@ public void missingOptionalParamArray() throws Exception {
571571
}
572572

573573
@Test
574-
@SuppressWarnings("rawtypes")
574+
@SuppressWarnings({ "rawtypes", "unchecked" })
575575
public void resolveOptionalParamList() throws Exception {
576576
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
577577
initializer.setConversionService(new DefaultConversionService());
@@ -588,7 +588,7 @@ public void resolveOptionalParamList() throws Exception {
588588
}
589589

590590
@Test
591-
@SuppressWarnings("rawtypes")
591+
@SuppressWarnings({ "rawtypes", "unchecked" })
592592
public void missingOptionalParamList() throws Exception {
593593
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
594594
initializer.setConversionService(new DefaultConversionService());

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void emptyParameterListHandleMethod(boolean usePathPatterns) throws Exception {
375375
assertThat(response.getContentAsString()).isEmpty();
376376
}
377377

378-
@SuppressWarnings("rawtypes")
378+
@SuppressWarnings({ "rawtypes", "unchecked" })
379379
@PathPatternsParameterizedTest
380380
void sessionAttributeExposure(boolean usePathPatterns) throws Exception {
381381
initDispatcherServlet(
@@ -405,7 +405,7 @@ void sessionAttributeExposure(boolean usePathPatterns) throws Exception {
405405
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
406406
}
407407

408-
@SuppressWarnings("rawtypes")
408+
@SuppressWarnings({ "rawtypes", "unchecked" })
409409
@PathPatternsParameterizedTest
410410
void sessionAttributeExposureWithInterface(boolean usePathPatterns) throws Exception {
411411
initDispatcherServlet(MySessionAttributesControllerImpl.class, usePathPatterns, wac -> {
@@ -438,7 +438,7 @@ void sessionAttributeExposureWithInterface(boolean usePathPatterns) throws Excep
438438
assertThat(((Map) session.getAttribute("model"))).containsKey("object2");
439439
}
440440

441-
@SuppressWarnings("rawtypes")
441+
@SuppressWarnings({ "rawtypes", "unchecked" })
442442
@PathPatternsParameterizedTest
443443
void parameterizedAnnotatedInterface(boolean usePathPatterns) throws Exception {
444444
initDispatcherServlet(
@@ -470,7 +470,7 @@ void parameterizedAnnotatedInterface(boolean usePathPatterns) throws Exception {
470470
assertThat(((Map) session.getAttribute("model"))).containsKey("testBeanList");
471471
}
472472

473-
@SuppressWarnings("rawtypes")
473+
@SuppressWarnings({ "rawtypes", "unchecked" })
474474
@PathPatternsParameterizedTest
475475
void parameterizedAnnotatedInterfaceWithOverriddenMappingsInImpl(boolean usePathPatterns) throws Exception {
476476
initDispatcherServlet(

0 commit comments

Comments
 (0)