private void extractMessages(
     final String property, final Errors errors, ValidatorMessageHolder holder) {
   ValidatorMessages messages = (ValidatorMessages) holder;
   for (ValidatorMessage message : messages) {
     errors.rejectValue(property, null, null, message.getDetail());
   }
 }
Esempio n. 2
0
  @Test()
  public void testValidateWithInteger() {
    longRangeValidator.setMax(100L);
    longRangeValidator.setMin(10L);
    ValidatorMessage message =
        (ValidatorMessage) longRangeValidator.validate(new Integer(21), "label");
    assertEquals(false, message.hasError());

    message = (ValidatorMessage) longRangeValidator.validate(new Integer(101), "label");
    assertEquals(true, message.hasError());

    message = (ValidatorMessage) longRangeValidator.validate(new Integer(9), "label");
    assertEquals(true, message.hasError());
  }
Esempio n. 3
0
  @Test()
  public void testValidateWithLong() {
    longRangeValidator.setMax(100L);
    longRangeValidator.setMin(10L);
    ValidatorMessage message =
        (ValidatorMessage) longRangeValidator.validate(new Long(21), "label");
    assertEquals(false, message.hasError());

    message = (ValidatorMessage) longRangeValidator.validate(new Long(101), "label");
    assertEquals(true, message.hasError());

    message = (ValidatorMessage) longRangeValidator.validate(new Long(9), "label");
    assertEquals(true, message.hasError());

    // ystem.out.println(message.getDetail());
    // ystem.out.println(message.getSummary());
  }