This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push: new 6af506d48 Add missing test for org.apache.commons.lang3.reflect.TypeUtils.parameterize(Class<?>, Map<TypeVariable<?>, Type>) 6af506d48 is described below commit 6af506d486c4e910418d84241e1c63a7fd2f3453 Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sun Jun 15 13:22:17 2025 -0400 Add missing test for org.apache.commons.lang3.reflect.TypeUtils.parameterize(Class<?>, Map<TypeVariable<?>, Type>) --- .../apache/commons/lang3/reflect/TypeUtilsTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java index 1602cfe4e..86da87771 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -956,10 +956,11 @@ void testLowerBoundedWildcardType() { } @Test - void testParameterize() throws NoSuchFieldException { - final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, String.class); - assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(), - stringComparableType)); + void testParameterizeMapArg() throws NoSuchFieldException { + final Map<TypeVariable<?>, Type> typeVariableMap = new HashMap<>(); + typeVariableMap.put(Comparable.class.getTypeParameters()[0], String.class); + final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, typeVariableMap); + assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(), stringComparableType)); assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString()); } @@ -979,6 +980,13 @@ void testParameterizeNullPointerException() { assertThrows(NullPointerException.class, () -> TypeUtils.parameterize(String.class, nullTypeVariableMap)); } + @Test + void testParameterizeVarArgs() throws NoSuchFieldException { + final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, String.class); + assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(), stringComparableType)); + assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString()); + } + @Test void testParameterizeVarArgsNullPointerException() { assertThrows(NullPointerException.class, () -> TypeUtils.parameterize(null)); @@ -1038,7 +1046,7 @@ void testTypesSatisfyVariables() throws NoSuchMethodException { @ParameterizedTest @MethodSource - void testTypeToString(Type type) { + void testTypeToString(final Type type) { // No stack overflow assertNotNull(TypeUtils.toString(type)); }