Skip to content

Commit 6af506d

Browse files
committed
Add missing test for
org.apache.commons.lang3.reflect.TypeUtils.parameterize(Class<?>, Map<TypeVariable<?>, Type>)
1 parent 97964af commit 6af506d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,11 @@ void testLowerBoundedWildcardType() {
956956
}
957957

958958
@Test
959-
void testParameterize() throws NoSuchFieldException {
960-
final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, String.class);
961-
assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(),
962-
stringComparableType));
959+
void testParameterizeMapArg() throws NoSuchFieldException {
960+
final Map<TypeVariable<?>, Type> typeVariableMap = new HashMap<>();
961+
typeVariableMap.put(Comparable.class.getTypeParameters()[0], String.class);
962+
final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, typeVariableMap);
963+
assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(), stringComparableType));
963964
assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString());
964965
}
965966

@@ -979,6 +980,13 @@ void testParameterizeNullPointerException() {
979980
assertThrows(NullPointerException.class, () -> TypeUtils.parameterize(String.class, nullTypeVariableMap));
980981
}
981982

983+
@Test
984+
void testParameterizeVarArgs() throws NoSuchFieldException {
985+
final ParameterizedType stringComparableType = TypeUtils.parameterize(Comparable.class, String.class);
986+
assertTrue(TypeUtils.equals(getClass().getField("stringComparable").getGenericType(), stringComparableType));
987+
assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString());
988+
}
989+
982990
@Test
983991
void testParameterizeVarArgsNullPointerException() {
984992
assertThrows(NullPointerException.class, () -> TypeUtils.parameterize(null));
@@ -1038,7 +1046,7 @@ void testTypesSatisfyVariables() throws NoSuchMethodException {
10381046

10391047
@ParameterizedTest
10401048
@MethodSource
1041-
void testTypeToString(Type type) {
1049+
void testTypeToString(final Type type) {
10421050
// No stack overflow
10431051
assertNotNull(TypeUtils.toString(type));
10441052
}

0 commit comments

Comments
 (0)