@@ -40,6 +40,7 @@ import org.mockito.quality.Strictness;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Jürgen Diez
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@@ -76,22 +77,39 @@ class ParameterizedTypeInformationUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-88
|
||||
void resolvesMapValueTypeCorrectly() {
|
||||
void resolvesMapTypesCorrectly() {
|
||||
|
||||
TypeInformation<Foo> type = ClassTypeInformation.from(Foo.class);
|
||||
var propertyType = type.getProperty("param");
|
||||
var value = propertyType.getProperty("value");
|
||||
|
||||
assertThat(propertyType.getComponentType().getType()).isEqualTo(Locale.class);
|
||||
assertThat(value.getType()).isEqualTo(String.class);
|
||||
assertThat(propertyType.getMapValueType().getType()).isEqualTo(String.class);
|
||||
|
||||
propertyType = type.getProperty("param2");
|
||||
value = propertyType.getProperty("value");
|
||||
|
||||
assertThat(propertyType.getComponentType().getType()).isEqualTo(String.class);
|
||||
assertThat(value.getType()).isEqualTo(String.class);
|
||||
assertThat(propertyType.getMapValueType().getType()).isEqualTo(Locale.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesVavrMapTypesCorrectly() {
|
||||
|
||||
TypeInformation<VavrFoo> type = ClassTypeInformation.from(VavrFoo.class);
|
||||
TypeInformation<?> propertyType = type.getProperty("param");
|
||||
|
||||
assertThat(propertyType.getComponentType().getType()).isEqualTo(Locale.class);
|
||||
assertThat(propertyType.getMapValueType().getType()).isEqualTo(String.class);
|
||||
|
||||
propertyType = type.getProperty("param2");
|
||||
|
||||
assertThat(propertyType.getComponentType().getType()).isEqualTo(String.class);
|
||||
assertThat(propertyType.getMapValueType().getType()).isEqualTo(Locale.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-446
|
||||
void createsToStringRepresentation() {
|
||||
|
||||
@@ -170,6 +188,11 @@ class ParameterizedTypeInformationUnitTests {
|
||||
Localized2<String> param2;
|
||||
}
|
||||
|
||||
class VavrFoo {
|
||||
io.vavr.collection.HashMap<Locale, String> param;
|
||||
io.vavr.collection.HashMap<String, Locale> param2;
|
||||
}
|
||||
|
||||
class Bar {
|
||||
List<String> param;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,15 @@ public class TypeDiscovererUnitTests {
|
||||
assertThat(type.isMap()).isTrue();
|
||||
}
|
||||
|
||||
@Test // #2517
|
||||
void returnsComponentAndValueTypesForVavrMapExtensions() {
|
||||
|
||||
var discoverer = new TypeDiscoverer<>(CustomVavrMap.class, EMPTY_MAP);
|
||||
|
||||
assertThat(discoverer.getMapValueType().getType()).isEqualTo(Locale.class);
|
||||
assertThat(discoverer.getComponentType().getType()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test // #2511
|
||||
void considerVavrSetToBeCollectionLike() {
|
||||
|
||||
@@ -260,4 +269,6 @@ public class TypeDiscovererUnitTests {
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
}
|
||||
|
||||
interface CustomVavrMap extends io.vavr.collection.Map<String, Locale> {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user