示例#1
0
  @Test
  public void testAggregateEmptyInValid() {
    Metric metric = new Metric("name", "", null, true, null, null);
    Set<ConstraintViolation<Metric>> violations = BeanValidationHelper.VALIDATOR.validate(metric);
    List<String> violationMessages = BeanValidationHelper.messagesFor(violations);

    assertThat(violationMessages.size(), equalTo(1));
    assertThat(violationMessages.get(0), equalTo("aggregate may not be empty"));
  }
示例#2
0
  @Test
  public void testUnitNullInvalid() {
    Metric metric = new Metric(null, "sum", null, true, null, null);
    Set<ConstraintViolation<Metric>> violations = BeanValidationHelper.VALIDATOR.validate(metric);
    List<String> violationMessages = BeanValidationHelper.messagesFor(violations);

    assertThat(violationMessages.size(), equalTo(1));
    assertThat(violationMessages.get(0), equalTo("name may not be null"));
  }