@Test @SpecAssertions({ @SpecAssertion(section = "6.11", id = "h"), @SpecAssertion(section = "6.11", id = "n") }) public void testComposingConstraints() { 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.getGroups().iterator().next(), Person.PersonValidation.class, "Wrong group"); } }
@Test @SpecAssertion(section = "6.11", id = "g") public void testDefaultGroupIsReturnedIfNoGroupSpecifiedInDeclaration() { ConstraintDescriptor<?> descriptor = getConstraintDescriptor(Order.class, "orderNumber"); Set<Class<?>> groups = descriptor.getGroups(); assertTrue(groups.size() == 1); assertEquals(groups.iterator().next(), Default.class, "Wrong group"); }
@Test @SpecAssertion(section = "6.11", id = "f") public void testGetGroupsOnInterface() { ConstraintDescriptor<?> descriptor = getConstraintDescriptor(Person.class, "lastName"); Set<Class<?>> groups = descriptor.getGroups(); assertTrue(groups.size() == 1); assertEquals(groups.iterator().next(), Default.class, "Wrong group"); }
@Test @SpecAssertion(section = "6.11", id = "f") public void testGetGroupsWithImplicitGroup() { ConstraintDescriptor<?> descriptor = getConstraintDescriptor(Man.class, "lastName"); Set<Class<?>> groups = descriptor.getGroups(); assertTrue(groups.size() == 2); for (Class<?> group : groups) { if (!(group.equals(Default.class) || group.equals(Person.class))) { fail("Invalid group."); } } }