@Test
  public void getTypeVariableTypeMirror() {
    List<? extends TypeParameterElement> typeVariables =
        getElement(Parameterized.class).getTypeParameters();

    // Members of converted types use ClassName and not Class<?>.
    ClassName number = ClassName.get(Number.class);
    ClassName runnable = ClassName.get(Runnable.class);
    ClassName serializable = ClassName.get(Serializable.class);

    assertThat(TypeName.get(typeVariables.get(0).asType()))
        .isEqualTo(TypeVariableName.get("Simple"));
    assertThat(TypeName.get(typeVariables.get(1).asType()))
        .isEqualTo(TypeVariableName.get("ExtendsClass", number));
    assertThat(TypeName.get(typeVariables.get(2).asType()))
        .isEqualTo(TypeVariableName.get("ExtendsInterface", runnable));
    assertThat(TypeName.get(typeVariables.get(3).asType()))
        .isEqualTo(TypeVariableName.get("ExtendsTypeVariable", TypeVariableName.get("Simple")));
    assertThat(TypeName.get(typeVariables.get(4).asType()))
        .isEqualTo(TypeVariableName.get("Intersection", number, runnable));
    assertThat(TypeName.get(typeVariables.get(5).asType()))
        .isEqualTo(TypeVariableName.get("IntersectionOfInterfaces", runnable, serializable));
    assertThat(((TypeVariableName) TypeName.get(typeVariables.get(4).asType())).bounds)
        .containsExactly(number, runnable);
  }
 @Test
 public void getBasicTypeMirror() {
   assertThat(TypeName.get(getMirror(Object.class))).isEqualTo(ClassName.get(Object.class));
   assertThat(TypeName.get(getMirror(Charset.class))).isEqualTo(ClassName.get(Charset.class));
   assertThat(TypeName.get(getMirror(AbstractTypesTest.class)))
       .isEqualTo(ClassName.get(AbstractTypesTest.class));
 }
 @Test
 public void getParameterizedTypeMirror() {
   DeclaredType setType =
       getTypes().getDeclaredType(getElement(Set.class), getMirror(Object.class));
   assertThat(TypeName.get(setType))
       .isEqualTo(ParameterizedTypeName.get(ClassName.get(Set.class), ClassName.OBJECT));
 }
 @Test
 public void box() throws Exception {
   assertThat(TypeName.INT.box()).isEqualTo(ClassName.get(Integer.class));
   assertThat(TypeName.VOID.box()).isEqualTo(ClassName.get(Void.class));
   assertThat(ClassName.get(Integer.class).box()).isEqualTo(ClassName.get(Integer.class));
   assertThat(ClassName.get(Void.class).box()).isEqualTo(ClassName.get(Void.class));
   assertThat(TypeName.OBJECT.box()).isEqualTo(TypeName.OBJECT);
   assertThat(ClassName.get(String.class).box()).isEqualTo(ClassName.get(String.class));
 }
 @Test
 public void unbox() throws Exception {
   assertThat(TypeName.INT).isEqualTo(TypeName.INT.unbox());
   assertThat(TypeName.VOID).isEqualTo(TypeName.VOID.unbox());
   assertThat(ClassName.get(Integer.class).unbox()).isEqualTo(TypeName.INT.unbox());
   assertThat(ClassName.get(Void.class).unbox()).isEqualTo(TypeName.VOID.unbox());
   try {
     TypeName.OBJECT.unbox();
     fail();
   } catch (UnsupportedOperationException expected) {
   }
   try {
     ClassName.get(String.class).unbox();
     fail();
   } catch (UnsupportedOperationException expected) {
   }
 }
 @Test
 public void getErrorType() {
   ErrorType errorType =
       new DeclaredTypeAsErrorType(getTypes().getDeclaredType(getElement(Set.class)));
   assertThat(TypeName.get(errorType)).isEqualTo(ClassName.get(Set.class));
 }