|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -565,6 +565,22 @@ void rawCollectionAsSource() throws Exception {
|
565 | 565 | assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("integerCollection")))).isEqualTo(Collections.singleton("testX"));
|
566 | 566 | }
|
567 | 567 |
|
| 568 | + @Test |
| 569 | + void stringListToListOfSubclassOfUnboundGenericClass() { |
| 570 | + conversionService.addConverter(new StringListToAListConverter()); |
| 571 | + conversionService.addConverter(new StringListToBListConverter()); |
| 572 | + |
| 573 | + List<ARaw> aList = (List<ARaw>) conversionService.convert(List.of("foo"), |
| 574 | + TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)), |
| 575 | + TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(ARaw.class))); |
| 576 | + assertThat(aList).allMatch(e -> e instanceof ARaw); |
| 577 | + |
| 578 | + List<BRaw> bList = (List<BRaw>) conversionService.convert(List.of("foo"), |
| 579 | + TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(String.class)), |
| 580 | + TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(BRaw.class))); |
| 581 | + assertThat(bList).allMatch(e -> e instanceof BRaw); |
| 582 | + } |
| 583 | + |
568 | 584 |
|
569 | 585 | @ExampleAnnotation(active = true)
|
570 | 586 | public String annotatedString;
|
@@ -740,6 +756,7 @@ public int getNestedMatchAttempts() {
|
740 | 756 | }
|
741 | 757 | }
|
742 | 758 |
|
| 759 | + |
743 | 760 | private interface MyEnumBaseInterface {
|
744 | 761 | String getBaseCode();
|
745 | 762 | }
|
@@ -921,4 +938,33 @@ public Color convert(String source) {
|
921 | 938 | return Color.decode(source.substring(0, 6));
|
922 | 939 | }
|
923 | 940 | }
|
| 941 | + |
| 942 | + |
| 943 | + private static class GenericBaseClass<T> { |
| 944 | + } |
| 945 | + |
| 946 | + private static class ARaw extends GenericBaseClass { |
| 947 | + } |
| 948 | + |
| 949 | + private static class BRaw extends GenericBaseClass { |
| 950 | + } |
| 951 | + |
| 952 | + |
| 953 | + private static class StringListToAListConverter implements Converter<List<String>, List<ARaw>> { |
| 954 | + |
| 955 | + @Override |
| 956 | + public List<ARaw> convert(List<String> source) { |
| 957 | + return List.of(new ARaw()); |
| 958 | + } |
| 959 | + } |
| 960 | + |
| 961 | + |
| 962 | + private static class StringListToBListConverter implements Converter<List<String>, List<BRaw>> { |
| 963 | + |
| 964 | + @Override |
| 965 | + public List<BRaw> convert(List<String> source) { |
| 966 | + return List.of(new BRaw()); |
| 967 | + } |
| 968 | + } |
| 969 | + |
924 | 970 | }
|
0 commit comments