|
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;
|
@@ -742,6 +758,7 @@ public int getNestedMatchAttempts() {
|
742 | 758 | }
|
743 | 759 | }
|
744 | 760 |
|
| 761 | + |
745 | 762 | private interface MyEnumBaseInterface {
|
746 | 763 | String getBaseCode();
|
747 | 764 | }
|
@@ -923,4 +940,33 @@ public Color convert(String source) {
|
923 | 940 | return Color.decode(source.substring(0, 6));
|
924 | 941 | }
|
925 | 942 | }
|
| 943 | + |
| 944 | + |
| 945 | + private static class GenericBaseClass<T> { |
| 946 | + } |
| 947 | + |
| 948 | + private static class ARaw extends GenericBaseClass { |
| 949 | + } |
| 950 | + |
| 951 | + private static class BRaw extends GenericBaseClass { |
| 952 | + } |
| 953 | + |
| 954 | + |
| 955 | + private static class StringListToAListConverter implements Converter<List<String>, List<ARaw>> { |
| 956 | + |
| 957 | + @Override |
| 958 | + public List<ARaw> convert(List<String> source) { |
| 959 | + return List.of(new ARaw()); |
| 960 | + } |
| 961 | + } |
| 962 | + |
| 963 | + |
| 964 | + private static class StringListToBListConverter implements Converter<List<String>, List<BRaw>> { |
| 965 | + |
| 966 | + @Override |
| 967 | + public List<BRaw> convert(List<String> source) { |
| 968 | + return List.of(new BRaw()); |
| 969 | + } |
| 970 | + } |
| 971 | + |
926 | 972 | }
|
0 commit comments