### Question:
ValidationController { public <T> void processBeanValidationForGroup(final T entity, Class<?>... groupClasses) { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<T>> errors = validator.validate(entity, groupClasses); if (!errors.isEmpty()) { throw new ConstraintViolationException(errors); } } private  ValidationController(); static ValidationController get(final Class<T> clazz); void processBeanValidation(final T entity); void processBeanValidationForProperty(final T entity, String propertyName); void processBeanValidationForGroup(final T entity, Class<?>... groupClasses);  }### Answer:
@Test public void processBeanValidationForGroup() throws Exception { TestEntity testEntity = new TestEntity(); testEntity.emptyOrSize = "abc"; testEntity.noSpace = "abc"; testEntity.notEmpty = "abcd"; try { ValidationController.get(TestEntity.class).processBeanValidationForGroup(testEntity, PasswordGroup.class); } catch (Exception ex) { fail("Correct values for the specified group are not recognized."); } testEntity.noSpace = "ab c"; try { ValidationController.get(TestEntity.class).processBeanValidationForGroup(testEntity, PasswordGroup.class); fail("Wrong value in 'noSpace' is not recognized"); } catch (Exception ex) { assertThat(ex, instanceOf(ConstraintViolationException.class)); assertThat(((ConstraintViolationException)ex).getConstraintViolations().size(), is(1)); } }