Search in sources :

Example 1 with ElementValidation

use of org.androidannotations.ElementValidation in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderFail3.

@Test
public void inOrderFail3() throws Exception {
    ExecutableElement executableElement = createMethod(boolean.class, boolean.class, long.class, Bundle.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(boolean.class.getName()).multiple().type(long.class.getName()).optional().type(int.class.getName()).optional().validate(executableElement, valid);
    assertFalse(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 2 with ElementValidation

use of org.androidannotations.ElementValidation in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method extendsViewType.

@Test
public void extendsViewType() throws Exception {
    ExecutableElement executableElement = createMethod(TextView.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    validator.extendsType(CanonicalNameConstants.VIEW).validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 3 with ElementValidation

use of org.androidannotations.ElementValidation in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderSuccess.

@Test
public void inOrderSuccess() throws Exception {
    ExecutableElement executableElement = createMethod(boolean.class, int.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(//
    boolean.class.getName()).type(long.class.getName()).optional().type(//
    int.class.getName()).validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 4 with ElementValidation

use of org.androidannotations.ElementValidation in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method inOrderFail4.

@Test
public void inOrderFail4() throws Exception {
    ExecutableElement executableElement = createMethod(int.class, long.class, boolean.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(boolean.class.getName()).optional().type(long.class.getName()).optional().type(int.class.getName()).optional().validate(executableElement, valid);
    assertFalse(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 5 with ElementValidation

use of org.androidannotations.ElementValidation in project androidannotations by androidannotations.

the class ValidatorParameterHelperTest method primitiveParam.

@Test
public void primitiveParam() throws Exception {
    ExecutableElement executableElement = createMethod(int.class, Integer.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    validator.primitiveOrWrapper(TypeKind.INT).multiple().validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Aggregations

ElementValidation (org.androidannotations.ElementValidation)17 ExecutableElement (javax.lang.model.element.ExecutableElement)15 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 Element (javax.lang.model.element.Element)1 AnnotationHandler (org.androidannotations.handler.AnnotationHandler)1 ValidationException (org.androidannotations.internal.exception.ValidationException)1