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

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


  }

  @Test
  public void testThatIsValidIfElementNumberIsBiggerThanCollectionSize() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));
    ArrayList<String> list = new ArrayList<String>();
    list.add("");
    list.add("");
    Assert.assertTrue(validator.isValid(list, context));
View Full Code Here


  }

  @Test
  public void testThatIsValidIfElementNumberIsBiggerThanNonNullArrayElements() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));

    Assert.assertTrue(validator.isValid(new Integer[100], context));
  }
View Full Code Here

  }

  @Test
  public void testThatIsInvalidIfElementNumberIsSmallerThanNonNullArrayElements() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));

    Integer[] array = new Integer[100];
    array[0] = 1;
    array[1] = 1;
View Full Code Here

  }

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfObjectIsArrayOfPrimitiveTypes() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));

    validator.isValid(new int[10], context);
  }
View Full Code Here

  }

  @Test(expected = IllegalStateException.class)
  public void testThatThrowsExceptionIfValueIsNegative() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator.initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class)
        .atField("c2"));
  }

  public static class AnnotatedModel {
    @MaxElements(2)
View Full Code Here

  private ConstraintValidatorContext context = Mockito.mock(ConstraintValidatorContext.class);

  @Test
  public void testThatNullIsValid() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));
    Assert.assertTrue(validator.isValid(null, context));
  }

  @Test(expected = IllegalStateException.class)
View Full Code Here

  }

  @Test
  public void testThatDoesNotThrowExceptionIfAnnotatedElementIsACollection() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));
    validator.isValid(new ArrayList<String>(), context);
  }

  @Test
View Full Code Here

  }

  @Test
  public void testThatDoesNotThrowsExceptionIfAnnotatedElementIsAnArray() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));
    validator.isValid(new Integer[10], context);
  }

  @Test
View Full Code Here

  }

  @Test
  public void testThatIsInvalidIfElementNumberIsSmallerThanCollectionSize() {
    StellaMaxElementsValidator validator = new StellaMaxElementsValidator();
    validator
        .initialize(new Mirror().on(AnnotatedModel.class).reflect().annotation(MaxElements.class).atField("c"));
    ArrayList<String> list = new ArrayList<String>();
    list.add("");
    list.add("");
    list.add("");
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.