Skip to content

Commit d6984c4

Browse files
committed
Add missing test coverage for
org.apache.commons.lang3.reflect.TypeUtils.toLongString(TypeVariable<?>) Use longer lines
1 parent a32cab8 commit d6984c4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ public static <U> Iterable<U> methodWithGenericReturnType() {
191191

192192
/** This non-static inner class is parameterized. */
193193
private class MyInnerClass<T> {
194-
// empty
194+
195+
class MyInnerClass2<X> {
196+
// empty
197+
}
195198
}
196199

197200
public class Other<T> implements This<String, T> {
@@ -1032,8 +1035,12 @@ void testParameterizeWithOwnerVarArgsNullPointerException() {
10321035

10331036
@Test
10341037
void testToLongString() {
1035-
assertEquals(getClass().getName() + ":B", TypeUtils.toLongString(getClass().getTypeParameters()[0]));
10361038
assertThrows(NullPointerException.class, () -> TypeUtils.toLongString(null));
1039+
assertEquals(getClass().getName() + ":B", TypeUtils.toLongString(getClass().getTypeParameters()[0]));
1040+
assertEquals(getClass().getName() + ".MyInnerClass:T", TypeUtils.toLongString(MyInnerClass.class.getTypeParameters()[0]));
1041+
assertEquals(getClass().getName() + ".That:K", TypeUtils.toLongString(That.class.getTypeParameters()[0]));
1042+
assertEquals(getClass().getName() + ".The:K", TypeUtils.toLongString(The.class.getTypeParameters()[0]));
1043+
assertEquals(getClass().getName() + ".MyInnerClass.MyInnerClass2:X", TypeUtils.toLongString(MyInnerClass.MyInnerClass2.class.getTypeParameters()[0]));
10371044
}
10381045

10391046
@Test
@@ -1074,19 +1081,15 @@ void testUnboundedWildcardType() {
10741081
assertArrayEquals(new Type[] { null }, TypeUtils.getImplicitLowerBounds(unbounded));
10751082
assertEquals("?", TypeUtils.toString(unbounded));
10761083
assertEquals("?", unbounded.toString());
1077-
1078-
assertThrows(NullPointerException.class,
1079-
() -> TypeUtils.getImplicitLowerBounds(null));
1080-
assertThrows(NullPointerException.class,
1081-
() -> TypeUtils.getImplicitUpperBounds(null));
1084+
assertThrows(NullPointerException.class, () -> TypeUtils.getImplicitLowerBounds(null));
1085+
assertThrows(NullPointerException.class, () -> TypeUtils.getImplicitUpperBounds(null));
10821086
}
10831087

10841088
@Test
10851089
void testWildcardType() throws NoSuchFieldException {
10861090
final WildcardType simpleWildcard = TypeUtils.wildcardType().withUpperBounds(String.class).build();
10871091
final Field cClass = AClass.class.getField("cClass");
1088-
assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0],
1089-
simpleWildcard));
1092+
assertTrue(TypeUtils.equals(((ParameterizedType) cClass.getGenericType()).getActualTypeArguments()[0], simpleWildcard));
10901093
assertEquals(String.format("? extends %s", String.class.getName()), TypeUtils.toString(simpleWildcard));
10911094
assertEquals(String.format("? extends %s", String.class.getName()), simpleWildcard.toString());
10921095
}
@@ -1095,7 +1098,6 @@ void testWildcardType() throws NoSuchFieldException {
10951098
void testWrap() {
10961099
final Type t = getClass().getTypeParameters()[0];
10971100
assertTrue(TypeUtils.equals(t, TypeUtils.wrap(t).getType()));
1098-
10991101
assertEquals(String.class, TypeUtils.wrap(String.class).getType());
11001102
}
11011103
}

0 commit comments

Comments
 (0)