@Test public void test_validate_all_properties_with_all_errors() throws Exception { errors = new MapBindingResult(new HashMap<>(), "OrgEnrollmentConfig"); when(request.getIdleDuration()).thenReturn("PT_invalid_idle_duration"); when(idleDurationReader.readParameter("PT_invalid_idle_duration", false)).thenThrow( new InvalidParameterException(Config.ServiceInstanceParameters.IDLE_DURATION, "Error")); when(request.getExcludeSpacesFromAutoEnrollment()).thenReturn("*_invalid_space_pattern"); when(excludeFromAutoEnrollmentReader.readParameter("*_invalid_space_pattern", false)) .thenThrow(new InvalidParameterException("exclude-spaces-from-auto-enrollment", "Error")); when(request.getAutoEnrollment()).thenReturn("non_standard"); when(autoEnrollmentReader.readParameter("non_standard", false)) .thenThrow(new InvalidParameterException("auto-enrollment", "Error")); when(request.getState()).thenReturn("not_backoffice_enrolled"); when(stateReader.readParameter("not_backoffice_enrolled", false)) .thenThrow(new InvalidParameterException("state", "Error")); enrollmentValidator.validate(request, errors); assertTrue(errors.getErrorCount() == 4); }
public void validate(Object target, Errors errors) { OrgEnrollmentConfigRequest orgEnrollmentConfig = (OrgEnrollmentConfigRequest) target; consumeParameter("idleDuration", orgEnrollmentConfig.getIdleDuration(), false, idleDurationReader, errors); consumeParameter("excludeSpacesFromAutoEnrollment", orgEnrollmentConfig.getExcludeSpacesFromAutoEnrollment(), false, excludeFromAutoEnrollmentReader, errors); consumeParameter("autoEnrollment", orgEnrollmentConfig.getAutoEnrollment(), false, autoEnrollmentReader, errors); consumeParameter("state", orgEnrollmentConfig.getState(), false, stateReader, errors); }
EnrollmentValidator implements Validator { public void validate(Object target, Errors errors) { OrgEnrollmentConfigRequest orgEnrollmentConfig = (OrgEnrollmentConfigRequest) target; consumeParameter("idleDuration", orgEnrollmentConfig.getIdleDuration(), false, idleDurationReader, errors); consumeParameter("excludeSpacesFromAutoEnrollment", orgEnrollmentConfig.getExcludeSpacesFromAutoEnrollment(), false, excludeFromAutoEnrollmentReader, errors); consumeParameter("autoEnrollment", orgEnrollmentConfig.getAutoEnrollment(), false, autoEnrollmentReader, errors); consumeParameter("state", orgEnrollmentConfig.getState(), false, stateReader, errors); } }
EnrollmentValidator implements Validator { public void validate(Object target, Errors errors) { OrgEnrollmentConfigRequest orgEnrollmentConfig = (OrgEnrollmentConfigRequest) target; consumeParameter("idleDuration", orgEnrollmentConfig.getIdleDuration(), false, idleDurationReader, errors); consumeParameter("excludeSpacesFromAutoEnrollment", orgEnrollmentConfig.getExcludeSpacesFromAutoEnrollment(), false, excludeFromAutoEnrollmentReader, errors); consumeParameter("autoEnrollment", orgEnrollmentConfig.getAutoEnrollment(), false, autoEnrollmentReader, errors); consumeParameter("state", orgEnrollmentConfig.getState(), false, stateReader, errors); }  }
EnrollmentValidator implements Validator { public void validate(Object target, Errors errors) { OrgEnrollmentConfigRequest orgEnrollmentConfig = (OrgEnrollmentConfigRequest) target; consumeParameter("idleDuration", orgEnrollmentConfig.getIdleDuration(), false, idleDurationReader, errors); consumeParameter("excludeSpacesFromAutoEnrollment", orgEnrollmentConfig.getExcludeSpacesFromAutoEnrollment(), false, excludeFromAutoEnrollmentReader, errors); consumeParameter("autoEnrollment", orgEnrollmentConfig.getAutoEnrollment(), false, autoEnrollmentReader, errors); consumeParameter("state", orgEnrollmentConfig.getState(), false, stateReader, errors); }  boolean supports(Class<?> clazz); void validate(Object target, Errors errors); }
EnrollmentValidator implements Validator { public void validate(Object target, Errors errors) { OrgEnrollmentConfigRequest orgEnrollmentConfig = (OrgEnrollmentConfigRequest) target; consumeParameter("idleDuration", orgEnrollmentConfig.getIdleDuration(), false, idleDurationReader, errors); consumeParameter("excludeSpacesFromAutoEnrollment", orgEnrollmentConfig.getExcludeSpacesFromAutoEnrollment(), false, excludeFromAutoEnrollmentReader, errors); consumeParameter("autoEnrollment", orgEnrollmentConfig.getAutoEnrollment(), false, autoEnrollmentReader, errors); consumeParameter("state", orgEnrollmentConfig.getState(), false, stateReader, errors); }  boolean supports(Class<?> clazz); void validate(Object target, Errors errors);  }