Search in sources :

Example 36 with TypeMirror

use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.

the class JavaTypeTest method fromIllegalArgumentException.

@Test
public void fromIllegalArgumentException() {
    // given
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Unsupported type: null");
    final TypeMirror typeMirror = mock(TypeMirror.class);
    when(typeMirror.getKind()).thenReturn(null);
    when(typeMirror.toString()).thenReturn(null);
    // when
    JavaType.from(typeMirror);
    // then
    fail("IllegalArgumentException expected.");
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) Test(org.junit.Test)

Example 37 with TypeMirror

use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.

the class JavaTypeTest method mockTypeMirror.

@NotNull
private static TypeMirror mockTypeMirror(@Nullable TypeKind typeKind, @Nullable String typeName) {
    final TypeMirror typeMirror = mock(TypeMirror.class);
    when(typeMirror.getKind()).thenReturn(typeKind);
    when(typeMirror.toString()).thenReturn(typeName);
    return typeMirror;
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with TypeMirror

use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.

the class JavaTypeTest method fromString.

@Test
public void fromString() {
    final TypeMirror typeMirror = mockTypeMirror(null, String.class.getCanonicalName());
    assertThat(JavaType.from(typeMirror)).isEqualTo(STRING);
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) Test(org.junit.Test)

Example 39 with TypeMirror

use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.

the class JavaTypeTest method fromFloat.

@Test
public void fromFloat() {
    final TypeMirror typeMirror = mockTypeMirror(TypeKind.FLOAT, null);
    assertThat(JavaType.from(typeMirror)).isEqualTo(FLOAT);
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) Test(org.junit.Test)

Example 40 with TypeMirror

use of javax.lang.model.type.TypeMirror in project storio by pushtorefresh.

the class JavaTypeTest method fromShort.

@Test
public void fromShort() {
    final TypeMirror typeMirror = mockTypeMirror(TypeKind.SHORT, null);
    assertThat(JavaType.from(typeMirror)).isEqualTo(SHORT);
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) Test(org.junit.Test)

Aggregations

TypeMirror (javax.lang.model.type.TypeMirror)475 TypeElement (javax.lang.model.element.TypeElement)197 ExecutableElement (javax.lang.model.element.ExecutableElement)105 Test (org.junit.Test)90 VariableElement (javax.lang.model.element.VariableElement)88 DeclaredType (javax.lang.model.type.DeclaredType)76 Element (javax.lang.model.element.Element)61 ArrayList (java.util.ArrayList)36 Expression (com.google.devtools.j2objc.ast.Expression)32 PrefixExpression (com.google.devtools.j2objc.ast.PrefixExpression)28 Elements (javax.lang.model.util.Elements)28 FunctionInvocation (com.google.devtools.j2objc.ast.FunctionInvocation)24 AbstractJClass (com.helger.jcodemodel.AbstractJClass)24 List (java.util.List)23 Types (javax.lang.model.util.Types)22 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)21 TypeParameterElement (javax.lang.model.element.TypeParameterElement)21 ArrayType (javax.lang.model.type.ArrayType)21 FunctionElement (com.google.devtools.j2objc.types.FunctionElement)20 IJExpression (com.helger.jcodemodel.IJExpression)20