Skip to content

Commit 505acb8

Browse files
dhaneesh646Dhaneeshgarydgregory
authored
Improve test coverage for TypeUtils.isAssignable (#1574)
* [LANG-1812] Test: Expose and test TypeUtils.isAssignable to improve coverage * Refactor: Revert method visibility to private and test via public API * Fix: Checkstyle violations (final keywords and whitespace) * Clean up tests --------- Co-authored-by: Dhaneesh <dhaneesh646@gmail.com@gmail.com> Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
1 parent 1436c59 commit 505acb8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,4 +1226,24 @@ void testWrap() {
12261226
assertTrue(TypeUtils.equals(t, TypeUtils.wrap(t).getType()));
12271227
assertEquals(String.class, TypeUtils.wrap(String.class).getType());
12281228
}
1229+
1230+
@Test
1231+
public void testIsAssignable_Type_TypeVariable_Map_Public() throws Exception {
1232+
class Container<T> {
1233+
}
1234+
final TypeVariable<?> typeVarT = Container.class.getTypeParameters()[0];
1235+
final boolean result = TypeUtils.isAssignable(Integer.class, typeVarT);
1236+
assertFalse(result);
1237+
}
1238+
1239+
@Test
1240+
public void testIsAssignable_HiddenMapLogic() {
1241+
class Container<T> {
1242+
}
1243+
class StringContainer extends Container<String> {
1244+
}
1245+
final Type stringContainerType = StringContainer.class.getGenericSuperclass();
1246+
assertTrue(TypeUtils.isAssignable(StringContainer.class, Container.class));
1247+
}
1248+
12291249
}

0 commit comments

Comments
 (0)