Skip to content

Commit

Permalink
Add a nested generics test for GenericTypeResolver
Browse files Browse the repository at this point in the history
Closes gh-31690
  • Loading branch information
sdeleuze committed Nov 29, 2023
1 parent 7cf124b commit df00aaf
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -194,6 +194,15 @@ public void resolveTransitiveTypeVariableWithDifferentName() {
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();
Expand Down Expand Up @@ -388,5 +397,10 @@ static class FirstSecondService implements First<Integer>, Second<String> {
static class SecondFirstService implements Second<String>, First<Integer> {
}

static class WithMethodParameter {
public void nestedGenerics(List<Map<String, Integer>> input) {
}
}


}

0 comments on commit df00aaf

Please sign in to comment.