Skip to content

Commit abaf81f

Browse files
committed
Clean up warnings in DefaultConversionServiceTests
1 parent 6bc14cc commit abaf81f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionServiceTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ public void convertCollectionToStringWithElementConversion() throws Exception {
510510
}
511511

512512
@Test
513+
@SuppressWarnings("rawtypes")
513514
public void convertStringToCollection() {
514515
List result = conversionService.convert("1,2,3", List.class);
515516
assertEquals(3, result.size());
@@ -519,6 +520,7 @@ public void convertStringToCollection() {
519520
}
520521

521522
@Test
523+
@SuppressWarnings("rawtypes")
522524
public void convertStringToCollectionWithElementConversion() throws Exception {
523525
List result = (List) conversionService.convert("1,2,3", TypeDescriptor.valueOf(String.class),
524526
new TypeDescriptor(getClass().getField("genericList")));
@@ -529,6 +531,7 @@ public void convertStringToCollectionWithElementConversion() throws Exception {
529531
}
530532

531533
@Test
534+
@SuppressWarnings("rawtypes")
532535
public void convertEmptyStringToCollection() {
533536
Collection result = conversionService.convert("", Collection.class);
534537
assertEquals(0, result.size());
@@ -557,6 +560,7 @@ public void convertCollectionToObjectAssignableTarget() throws Exception {
557560
}
558561

559562
@Test
563+
@SuppressWarnings("rawtypes")
560564
public void convertCollectionToObjectWithCustomConverter() throws Exception {
561565
List<String> source = new ArrayList<String>();
562566
source.add("A");
@@ -572,8 +576,8 @@ public ListWrapper convert(List source) {
572576
}
573577

574578
@Test
579+
@SuppressWarnings({ "cast", "unchecked" })
575580
public void convertObjectToCollection() {
576-
@SuppressWarnings("unchecked")
577581
List<String> result = (List<String>) conversionService.convert(3L, List.class);
578582
assertEquals(1, result.size());
579583
assertEquals(3L, result.get(0));
@@ -652,6 +656,7 @@ public void convertCollectionToCollectionNull() throws Exception {
652656
}
653657

654658
@Test
659+
@SuppressWarnings("rawtypes")
655660
public void convertCollectionToCollectionNotGeneric() throws Exception {
656661
Set<String> foo = new LinkedHashSet<String>();
657662
foo.add("1");
@@ -664,8 +669,8 @@ public void convertCollectionToCollectionNotGeneric() throws Exception {
664669
assertEquals("3", bar.get(2));
665670
}
666671

667-
@SuppressWarnings("unchecked")
668672
@Test
673+
@SuppressWarnings({ "unchecked", "rawtypes" })
669674
public void convertCollectionToCollectionSpecialCaseSourceImpl() throws Exception {
670675
Map map = new LinkedHashMap();
671676
map.put("1", "1");
@@ -783,9 +788,6 @@ public void convertObjectToStringUsingToString() {
783788
SSN.reset();
784789
assertEquals("123456789", conversionService.convert(new SSN("123456789"), String.class));
785790

786-
// TODO What if the target type has a static factory method that takes precedence
787-
// over the source type's toString() method?
788-
789791
assertEquals("constructor invocations", 1, SSN.constructorCount);
790792
assertEquals("toString() invocations", 1, SSN.toStringCount);
791793
}
@@ -863,6 +865,7 @@ public char[] convert(String source) {
863865
}
864866

865867
@Test
868+
@SuppressWarnings("unchecked")
866869
public void multidimensionalArrayToListConversionShouldConvertEntriesCorrectly() {
867870
String[][] grid = new String[][] { new String[] { "1", "2", "3", "4" }, new String[] { "5", "6", "7", "8" },
868871
new String[] { "9", "10", "11", "12" } };
@@ -1035,7 +1038,6 @@ private static class ISBN {
10351038

10361039
static int constructorCount = 0;
10371040
static int toStringCount = 0;
1038-
10391041
static int valueOfCount = 0;
10401042

10411043
static void reset() {
@@ -1046,7 +1048,7 @@ static void reset() {
10461048

10471049
private final String value;
10481050

1049-
private ISBN(String value) {
1051+
public ISBN(String value) {
10501052
constructorCount++;
10511053
this.value = value;
10521054
}

0 commit comments

Comments
 (0)