package dagger.internal.codegen.writer;

import com.google.testing.compile.CompilationRule;
import java.nio.charset.Charset;
import java.util.Set;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static com.google.common.truth.Truth.ASSERT;

@RunWith(JUnit4.class)
public class TypeNamesTest {
  @Rule public final CompilationRule compilation = new CompilationRule();

  private TypeElement getElement(Class<?> clazz) {
    return compilation.getElements().getTypeElement(clazz.getCanonicalName());
  }

  private TypeMirror getType(Class<?> clazz) {
    return getElement(clazz).asType();
  }

  @Test
  public void forTypeMirror_basicTypes() {
    ASSERT.that(TypeNames.forTypeMirror(getType(Object.class)))
        .isEqualTo(ClassName.fromClass(Object.class));
    ASSERT.that(TypeNames.forTypeMirror(getType(Charset.class)))
        .isEqualTo(ClassName.fromClass(Charset.class));
    ASSERT.that(TypeNames.forTypeMirror(getType(TypeNamesTest.class)))
        .isEqualTo(ClassName.fromClass(TypeNamesTest.class));
  }

  @Test
  public void forTypeMirror_parameterizedType() {
    DeclaredType setType =
        compilation.getTypes().getDeclaredType(getElement(Set.class), getType(Object.class));
    ASSERT.that(TypeNames.forTypeMirror(setType))
        .isEqualTo(ParameterizedTypeName.create(Set.class, ClassName.fromClass(Object.class)));
  }

  @Test
  public void forTypeMirror_primitive() {
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.BOOLEAN)))
        .isEqualTo(PrimitiveName.BOOLEAN);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.BYTE)))
        .isEqualTo(PrimitiveName.BYTE);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.SHORT)))
        .isEqualTo(PrimitiveName.SHORT);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.INT)))
        .isEqualTo(PrimitiveName.INT);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.LONG)))
        .isEqualTo(PrimitiveName.LONG);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.CHAR)))
        .isEqualTo(PrimitiveName.CHAR);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.FLOAT)))
        .isEqualTo(PrimitiveName.FLOAT);
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getPrimitiveType(TypeKind.DOUBLE)))
        .isEqualTo(PrimitiveName.DOUBLE);
  }

  @Test
  public void forTypeMirror_arrays() {
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getArrayType(getType(Object.class))))
        .isEqualTo(new ArrayTypeName(ClassName.fromClass(Object.class)));
  }

  @Test
  public void forTypeMirror_void() {
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getNoType(TypeKind.VOID)))
        .isEqualTo(VoidName.VOID);
  }

  @Test
  public void forTypeMirror_null() {
    ASSERT.that(TypeNames.forTypeMirror(compilation.getTypes().getNullType()))
        .isEqualTo(NullName.NULL);
  }
}

@@ -465,22 +465,23 @@
 h.Truth.
-ASSERT
+assert_
 ;%0A%0A@RunW
@@ -875,38 +875,41 @@
 icTypes() %7B%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -997,38 +997,41 @@
 ct.class));%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -1121,38 +1121,41 @@
 et.class));%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -1445,30 +1445,33 @@
 lass));%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -1645,38 +1645,41 @@
 imitive() %7B%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -1795,30 +1795,33 @@
 OLEAN);%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -1935,30 +1935,33 @@
 .BYTE);%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -2073,38 +2073,41 @@
 ame.SHORT);%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -2211,38 +2211,41 @@
 eName.INT);%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -2355,30 +2355,33 @@
 .LONG);%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -2495,30 +2495,33 @@
 .CHAR);%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -2637,30 +2637,33 @@
 FLOAT);%0A    
-ASSERT
+assert_()
 .that(TypeNa
@@ -2829,38 +2829,41 @@
 _arrays() %7B%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -3057,38 +3057,41 @@
 or_void() %7B%0A    
-ASSERT
+assert_()
 .that(TypeNames.
@@ -3247,14 +3247,17 @@
     
-ASSERT
+assert_()
 .tha

Use Truth.assert_() instead of ASSERT ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72726400