コード例 #1
0
  @Test
  @SpecAssertion(section = "6.11", id = "i")
  public void testPayload() {
    ConstraintDescriptor<?> descriptor = getConstraintDescriptor(Person.class, "firstName");
    Set<Class<? extends Payload>> payload = descriptor.getPayload();
    assertTrue(payload.size() == 1);
    assertEquals(payload.iterator().next(), Severity.Info.class, "Wrong payload");

    descriptor = getConstraintDescriptor(Order.class, "orderNumber");
    payload = descriptor.getPayload();
    assertTrue(payload != null);
    assertTrue(payload.size() == 0);
  }
コード例 #2
0
 @Test
 @SpecAssertions({
   @SpecAssertion(section = "6.11", id = "j"),
   @SpecAssertion(section = "6.11", id = "k")
 })
 public void testComposingConstraintsPayload() {
   ConstraintDescriptor<?> descriptor = getConstraintDescriptor(Person.class, "firstName");
   Set<ConstraintDescriptor<?>> composingDescriptors = descriptor.getComposingConstraints();
   assertEquals(composingDescriptors.size(), 2, "Wrong number of composing constraints");
   for (ConstraintDescriptor<?> desc : composingDescriptors) {
     assertTrue(desc.getGroups().size() == 1);
     assertEquals(desc.getPayload().iterator().next(), Severity.Info.class, "Wrong payload");
   }
 }