Search in sources :

Example 11 with ElementValidation

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

the class ValidatorParameterHelperTest method stringParam.

@Test
public void stringParam() throws Exception {
    ExecutableElement executableElement = createMethod(String.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    validator.type(CanonicalNameConstants.STRING).validate(executableElement, valid);
    assertTrue(valid.isValid());
    executableElement = createMethod(int.class);
    valid = new ElementValidation("", executableElement);
    validator.noParam().validate(executableElement, valid);
    assertFalse(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 12 with ElementValidation

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

the class ValidatorParameterHelperTest method annotatedParam.

@Test
public void annotatedParam() throws Exception {
    ExecutableElement executableElement = createMethod(p(String.class, TestAnnotation.class));
    ElementValidation valid = new ElementValidation("", executableElement);
    validator.annotatedWith(TestAnnotation.class).validate(executableElement, valid);
    assertTrue(valid.isValid());
}
Also used : ExecutableElement(javax.lang.model.element.ExecutableElement) ElementValidation(org.androidannotations.ElementValidation) Test(org.junit.Test)

Example 13 with ElementValidation

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

the class ValidatorParameterHelperTest method inOrderSuccess2.

@Test
public void inOrderSuccess2() throws Exception {
    ExecutableElement executableElement = createMethod(boolean.class, boolean.class, int.class);
    ElementValidation valid = new ElementValidation("", executableElement);
    //
    validator.inOrder().type(boolean.class.getName()).multiple().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 14 with ElementValidation

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

the class ValidatorParameterHelperTest method noParam.

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

Example 15 with ElementValidation

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

the class ValidatorParameterHelperTest method inOrderFail2.

@Test
public void inOrderFail2() throws Exception {
    ExecutableElement executableElement = createMethod(long.class, boolean.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)

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