@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 typeVariable() throws Exception { TypeVariableName type = TypeVariableName.get("T", CharSequence.class); assertThat(type.toString()).isEqualTo("T"); // (Bounds are only emitted in declaration.) }