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

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


  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));
  }

  @Test
  public void testThatIsInvalidIfStringIsSmallerThanParameter() {
View Full Code Here


  }

  @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));
  }

  @Test
  public void testThatIsInvalidIfStringIsBiggerThanParameter() {
View Full Code Here

  }

  @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));
  }

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfMinIsBiggerThanMax() {
View Full Code Here

  }

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

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfMinIsNegative() {
    StellaLengthValidator validator = new StellaLengthValidator();
View Full Code Here

  }

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

  @Test
  public void testThatIsValidIfBetweenMaxAndMin() {
    StellaLengthValidator validator = new StellaLengthValidator();
View Full Code Here

  }

  @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));
  }

  public static class AnnotatedModel {
    @Length
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.