### Question:
Group { @Override public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } Group group1 = ( Group ) o; if ( group != null ? !group.equals( group1.group ) : group1.group != null ) { return false; } if ( sequence != null ? !sequence.equals( group1.sequence ) : group1.sequence != null ) { return false; } return true; } Group(Class<?> group);  Group(Class<?> group, Class<?> sequence); Class<?> getGroup(); boolean partOfSequence(); Class<?> getSequence(); @Override boolean equals(Object o); boolean isDefaultGroup(); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testGroupSequenceFollowedByGroup() { User user = new User(); user.setFirstname( "Foo" ); user.setLastname( "Bar" ); user.setPhoneNumber( "+46 123-456" ); Validator validator = TestUtil.getValidator(); Set<ConstraintViolation<User>> constraintViolations = validator.validate( user, BuyInOneClick.class, Optional.class ); assertEquals( constraintViolations.size(), 2, "There should be two violations against the implicit default group" ); for ( ConstraintViolation<User> constraintViolation : constraintViolations ) { if ( constraintViolation.getPropertyPath().equals( "defaultCreditCard" ) ) { assertConstraintViolation( constraintViolation, "may not be null", User.class, null, "defaultCreditCard" ); } else if ( constraintViolation.getPropertyPath().equals( "phoneNumber" ) ) { assertConstraintViolation( constraintViolation, "must match \"[0-9 -]?\"", User.class, "+46 123-456", "phoneNumber" ); } else { fail( "Unexpected violation" ); } } }