Package br.com.caelum.stella.bean.validation.xml.logic

Examples of br.com.caelum.stella.bean.validation.xml.logic.StellaLengthValidator


public class StellaLengthValidatorTest {
  private ConstraintValidatorContext context = Mockito.mock(ConstraintValidatorContext.class);

  @Test
  public void testThatNullIsValid() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("foo"));
    Assert.assertTrue(validator.isValid(null, context));
  }
View Full Code Here


    Assert.assertTrue(validator.isValid(null, context));
  }

  @Test
  public void testThatIsInvalidIfStringIsSmallerThanParameter() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s1"));
    Assert.assertFalse(validator.isValid("as", context));
  }
View Full Code Here

    Assert.assertFalse(validator.isValid("as", context));
  }

  @Test
  public void testThatIsInvalidIfStringIsBiggerThanParameter() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s2"));
    Assert.assertFalse(validator.isValid("12345678912", context));
  }
View Full Code Here

    Assert.assertFalse(validator.isValid("12345678912", context));
  }

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfMinIsBiggerThanMax() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s4"));
  }
View Full Code Here

    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s4"));
  }

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfMinIsNegative() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s5"));
  }
View Full Code Here

    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s5"));
  }

  @Test
  public void testThatIsValidIfBetweenMaxAndMin() {
    StellaLengthValidator validator = new StellaLengthValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(Length.class).atField("s3"));
    Assert.assertTrue(validator.isValid("1234567890", context));
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.stella.bean.validation.xml.logic.StellaLengthValidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.