Skip to content

Commit a32cab8

Browse files
committed
Add missing test coverage for
org.apache.commons.lang3.reflect.TypeUtils.parameterizeWithOwner(Type, Class<?>, Map<TypeVariable<?>, Type>)
1 parent b7a82af commit a32cab8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ void testParameterizeWithOwner3ArgsNullPointerException() {
10151015
assertThrows(NullPointerException.class, () -> TypeUtils.parameterizeWithOwner(owner, null, String.class));
10161016
final Map<TypeVariable<?>, Type> nullTypeVariableMap = null;
10171017
assertThrows(NullPointerException.class, () -> TypeUtils.parameterizeWithOwner(owner, That.class, nullTypeVariableMap));
1018+
final Map<TypeVariable<?>, Type> typeVariableMap1 = new HashMap<>();
1019+
typeVariableMap1.put(Comparable.class.getTypeParameters()[0], String.class);
1020+
assertEquals(Comparable.class, TypeUtils.parameterizeWithOwner(null, Comparable.class, typeVariableMap1).getRawType());
1021+
final Map<TypeVariable<?>, Type> typeVariableMap2 = new HashMap<>();
1022+
typeVariableMap2.put(MyInnerClass.class.getTypeParameters()[0], String.class);
1023+
assertEquals(MyInnerClass.class, TypeUtils.parameterizeWithOwner(null, MyInnerClass.class, typeVariableMap2).getRawType());
1024+
assertEquals(MyInnerClass.class, TypeUtils.parameterizeWithOwner(owner, MyInnerClass.class, typeVariableMap2).getRawType());
10181025
}
10191026

10201027
@Test
@@ -1026,7 +1033,6 @@ void testParameterizeWithOwnerVarArgsNullPointerException() {
10261033
@Test
10271034
void testToLongString() {
10281035
assertEquals(getClass().getName() + ":B", TypeUtils.toLongString(getClass().getTypeParameters()[0]));
1029-
10301036
assertThrows(NullPointerException.class, () -> TypeUtils.toLongString(null));
10311037
}
10321038

@@ -1050,7 +1056,6 @@ void testTypesSatisfyVariables() throws NoSuchMethodException {
10501056
typeVarAssigns.clear();
10511057
typeVarAssigns.put(getClass().getMethod("stub3").getTypeParameters()[0], Integer.class);
10521058
assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns));
1053-
10541059
assertThrows(NullPointerException.class, () -> TypeUtils.typesSatisfyVariables(null));
10551060
}
10561061

0 commit comments

Comments
 (0)