Browse Source

Add a nested generics test for GenericTypeResolver

Closes gh-31690
pull/30079/head
Sébastien Deleuze 2 years ago
parent
commit
df00aafdff
  1. 16
      spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

16
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -194,6 +194,15 @@ class GenericTypeResolverTests { @@ -194,6 +194,15 @@ class GenericTypeResolverTests {
assertThat(resolved).isEqualTo(E.class);
}
@Test
public void resolveMethodParameterWithNestedGenerics() {
Method method = method(WithMethodParameter.class, "nestedGenerics", List.class);
MethodParameter methodParameter = new MethodParameter(method, 0);
Type resolvedType = resolveType(methodParameter.getGenericParameterType(), WithMethodParameter.class);
ParameterizedTypeReference<List<Map<String, Integer>>> reference = new ParameterizedTypeReference<>() {};
assertThat(resolvedType).isEqualTo(reference.getType());
}
private static Method method(Class<?> target, String methodName, Class<?>... parameterTypes) {
Method method = findMethod(target, methodName, parameterTypes);
assertThat(method).describedAs(target.getName() + "#" + methodName).isNotNull();
@ -388,5 +397,10 @@ class GenericTypeResolverTests { @@ -388,5 +397,10 @@ class GenericTypeResolverTests {
static class SecondFirstService implements Second<String>, First<Integer> {
}
static class WithMethodParameter {
public void nestedGenerics(List<Map<String, Integer>> input) {
}
}
}

Loading…
Cancel
Save