### Question:
AnnotatedTypes { @Nonnull public static AnnotatedType fromType(@Nonnull Type type) { checkNotNull(type); checkArgument(!(type instanceof TypeVariable), "Type must not be a type variable"); checkArgument(!(type instanceof WildcardType), "Type must not be a wildcard type"); if (type instanceof Class) { Class<?> clazz = (Class<?>) type; return clazz.isArray() ? new UnAnnotatedArrayType(clazz) : new UnAnnotatedType(clazz); } else if (type instanceof ParameterizedType) { return new UnAnnotatedParameterizedType((ParameterizedType) type); } else if (type instanceof GenericArrayType) { return new UnAnnotatedArrayType((GenericArrayType) type); } throw new AssertionError(); } private  AnnotatedTypes(); @Nonnull static AnnotatedType fromType(@Nonnull Type type); @Nonnull static AnnotatedType[] getActualTypeArguments(@Nonnull AnnotatedType type); static final AnnotatedType STRING; }### Answer:
@Test void testRawType() { AnnotatedType type = AnnotatedTypes.fromType(Object.class); assertEquals(Object.class, type.getType(), "AnnotatedType did not return correct type"); assertFalse(type instanceof AnnotatedParameterizedType || type instanceof AnnotatedArrayType, "Raw type was assigned an incorrect subtype of AnnotatedType"); }
@SuppressWarnings("UnstableApiUsage") @Test void testParameterizedType() { TypeToken<List<Object>> token = new TypeToken<List<Object>>() { }; AnnotatedType type = AnnotatedTypes.fromType(token.getType()); assertEquals(token.getType(), type.getType(), "AnnotatedType did not return correct type"); assertTrue(type instanceof AnnotatedParameterizedType, "Parameterized type was assigned an incorrect subtype of AnnotatedType"); assertEquals(Object.class, ((AnnotatedParameterizedType) type) .getAnnotatedActualTypeArguments()[0].getType(), "Actual type argument of AnnotatedType and provided type differ"); }
@Test void testRawArrayType() { AnnotatedType type = AnnotatedTypes.fromType(Object[].class); assertEquals(Object[].class, type.getType(), "AnnotatedType did not return correct type"); assertTrue(type instanceof AnnotatedArrayType, "Array type was assigned an incorrect subtype of AnnotatedType"); assertEquals(Object.class, ((AnnotatedArrayType) type).getAnnotatedGenericComponentType().getType(), "Component type of AnnotatedType and provided type differ"); }
@SuppressWarnings("UnstableApiUsage") @Test void testGenericArrayType() { TypeToken<List<Object>[]> token = new TypeToken<List<Object>[]>() { }; AnnotatedType type = AnnotatedTypes.fromType(token.getType()); assertEquals(token.getType(), type.getType(), "AnnotatedType did not return correct type"); assertTrue(type instanceof AnnotatedArrayType, "Array type was assigned an incorrect subtype of AnnotatedType"); TypeToken<List<Object>> componentToken = new TypeToken<List<Object>>() { }; assertEquals(componentToken.getType(), ((AnnotatedArrayType) type).getAnnotatedGenericComponentType().getType(), "Component type of AnnotatedType and provided type differ"); }