Code example for ParameterizedType

Methods: getActualTypeArguments, getOwnerType, getRawType

0
    public void testStringParameterizedSuperClass() { 
        Class<? extends B> clazz = B.class;
        Type genericSuperclass = clazz.getGenericSuperclass();
        assertInstanceOf(ParameterizedType.class, genericSuperclass);
        ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
        assertEquals(ParameterizedTypeTest.class, parameterizedType.getOwnerType());
        assertEquals(A.class, parameterizedType.getRawType());
 
        Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
        assertLenghtOne(actualTypeArguments);
        assertEquals(String.class, actualTypeArguments[0]);
    } 
 
    static class C<T>{} 
    static class D<T> extends C<T>{} 
 
    @TestTargets({ 
        @TestTargetNew( 
            level = TestLevel.SUFFICIENT, 
            notes = "Missing tests for TypeNotPresentException, MalformedParametrizedTypeException", 
            method = "getActualTypeArguments",