@Test public void getTypeVariableTypeMirrorRecursive() { TypeMirror typeMirror = getElement(Recursive.class).asType(); ParameterizedTypeName typeName = (ParameterizedTypeName) TypeName.get(typeMirror); String className = Recursive.class.getCanonicalName(); assertThat(typeName.toString()).isEqualTo(className + "<T>"); TypeVariableName typeVariableName = (TypeVariableName) typeName.typeArguments.get(0); try { typeVariableName.bounds.set(0, null); fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException expected) { } assertThat(typeVariableName.toString()).isEqualTo("T"); assertThat(typeVariableName.bounds.toString()) .isEqualTo("[java.util.Map<java.util.List<T>, java.util.Set<T[]>>]"); }
@Test public void parameterizedType() throws Exception { ParameterizedTypeName type = ParameterizedTypeName.get(Map.class, String.class, Long.class); assertThat(type.toString()).isEqualTo("java.util.Map<java.lang.String, java.lang.Long>"); }