@Test void validationSucceeds() { AwsParamStoreProperties properties = new AwsParamStorePropertiesBuilder() .withPrefix("/con").withDefaultContext("app").withProfileSeparator("_") .build(); Errors errors = new BeanPropertyBindingResult(properties, "properties"); properties.validate(properties, errors); assertThat(errors.getAllErrors()).isEmpty(); }
@Override public void validate(Object target, Errors errors) { AwsParamStoreProperties properties = (AwsParamStoreProperties) target; if (StringUtils.isEmpty(properties.getPrefix())) { errors.rejectValue("prefix", "NotEmpty", "prefix should not be empty or null."); } if (StringUtils.isEmpty(properties.getDefaultContext())) { errors.rejectValue("defaultContext", "NotEmpty", "defaultContext should not be empty or null."); } if (StringUtils.isEmpty(properties.getProfileSeparator())) { errors.rejectValue("profileSeparator", "NotEmpty", "profileSeparator should not be empty or null."); } if (!PREFIX_PATTERN.matcher(properties.getPrefix()).matches()) { errors.rejectValue("prefix", "Pattern", "The prefix must have pattern of: " + PREFIX_PATTERN.toString()); } if (!PROFILE_SEPARATOR_PATTERN.matcher(properties.getProfileSeparator()) .matches()) { errors.rejectValue("profileSeparator", "Pattern", "The profileSeparator must have pattern of: " + PROFILE_SEPARATOR_PATTERN.toString()); } }
AwsParamStoreProperties implements Validator { @Override public void validate(Object target, Errors errors) { AwsParamStoreProperties properties = (AwsParamStoreProperties) target; if (StringUtils.isEmpty(properties.getPrefix())) { errors.rejectValue("prefix", "NotEmpty", "prefix should not be empty or null."); } if (StringUtils.isEmpty(properties.getDefaultContext())) { errors.rejectValue("defaultContext", "NotEmpty", "defaultContext should not be empty or null."); } if (StringUtils.isEmpty(properties.getProfileSeparator())) { errors.rejectValue("profileSeparator", "NotEmpty", "profileSeparator should not be empty or null."); } if (!PREFIX_PATTERN.matcher(properties.getPrefix()).matches()) { errors.rejectValue("prefix", "Pattern", "The prefix must have pattern of: " + PREFIX_PATTERN.toString()); } if (!PROFILE_SEPARATOR_PATTERN.matcher(properties.getProfileSeparator()) .matches()) { errors.rejectValue("profileSeparator", "Pattern", "The profileSeparator must have pattern of: " + PROFILE_SEPARATOR_PATTERN.toString()); } } }
AwsParamStoreProperties implements Validator { @Override public void validate(Object target, Errors errors) { AwsParamStoreProperties properties = (AwsParamStoreProperties) target; if (StringUtils.isEmpty(properties.getPrefix())) { errors.rejectValue("prefix", "NotEmpty", "prefix should not be empty or null."); } if (StringUtils.isEmpty(properties.getDefaultContext())) { errors.rejectValue("defaultContext", "NotEmpty", "defaultContext should not be empty or null."); } if (StringUtils.isEmpty(properties.getProfileSeparator())) { errors.rejectValue("profileSeparator", "NotEmpty", "profileSeparator should not be empty or null."); } if (!PREFIX_PATTERN.matcher(properties.getPrefix()).matches()) { errors.rejectValue("prefix", "Pattern", "The prefix must have pattern of: " + PREFIX_PATTERN.toString()); } if (!PROFILE_SEPARATOR_PATTERN.matcher(properties.getProfileSeparator()) .matches()) { errors.rejectValue("profileSeparator", "Pattern", "The profileSeparator must have pattern of: " + PROFILE_SEPARATOR_PATTERN.toString()); } }  }
AwsParamStoreProperties implements Validator { @Override public void validate(Object target, Errors errors) { AwsParamStoreProperties properties = (AwsParamStoreProperties) target; if (StringUtils.isEmpty(properties.getPrefix())) { errors.rejectValue("prefix", "NotEmpty", "prefix should not be empty or null."); } if (StringUtils.isEmpty(properties.getDefaultContext())) { errors.rejectValue("defaultContext", "NotEmpty", "defaultContext should not be empty or null."); } if (StringUtils.isEmpty(properties.getProfileSeparator())) { errors.rejectValue("profileSeparator", "NotEmpty", "profileSeparator should not be empty or null."); } if (!PREFIX_PATTERN.matcher(properties.getPrefix()).matches()) { errors.rejectValue("prefix", "Pattern", "The prefix must have pattern of: " + PREFIX_PATTERN.toString()); } if (!PROFILE_SEPARATOR_PATTERN.matcher(properties.getProfileSeparator()) .matches()) { errors.rejectValue("profileSeparator", "Pattern", "The profileSeparator must have pattern of: " + PROFILE_SEPARATOR_PATTERN.toString()); } }  @Override boolean supports(Class clazz); @Override void validate(Object target, Errors errors); String getPrefix(); void setPrefix(String prefix); String getDefaultContext(); void setDefaultContext(String defaultContext); String getProfileSeparator(); void setProfileSeparator(String profileSeparator); boolean isFailFast(); void setFailFast(boolean failFast); String getName(); void setName(String name); boolean isEnabled(); void setEnabled(boolean enabled); String getRegion(); void setRegion(final String region); }
AwsParamStoreProperties implements Validator { @Override public void validate(Object target, Errors errors) { AwsParamStoreProperties properties = (AwsParamStoreProperties) target; if (StringUtils.isEmpty(properties.getPrefix())) { errors.rejectValue("prefix", "NotEmpty", "prefix should not be empty or null."); } if (StringUtils.isEmpty(properties.getDefaultContext())) { errors.rejectValue("defaultContext", "NotEmpty", "defaultContext should not be empty or null."); } if (StringUtils.isEmpty(properties.getProfileSeparator())) { errors.rejectValue("profileSeparator", "NotEmpty", "profileSeparator should not be empty or null."); } if (!PREFIX_PATTERN.matcher(properties.getPrefix()).matches()) { errors.rejectValue("prefix", "Pattern", "The prefix must have pattern of: " + PREFIX_PATTERN.toString()); } if (!PROFILE_SEPARATOR_PATTERN.matcher(properties.getProfileSeparator()) .matches()) { errors.rejectValue("profileSeparator", "Pattern", "The profileSeparator must have pattern of: " + PROFILE_SEPARATOR_PATTERN.toString()); } }  @Override boolean supports(Class clazz); @Override void validate(Object target, Errors errors); String getPrefix(); void setPrefix(String prefix); String getDefaultContext(); void setDefaultContext(String defaultContext); String getProfileSeparator(); void setProfileSeparator(String profileSeparator); boolean isFailFast(); void setFailFast(boolean failFast); String getName(); void setName(String name); boolean isEnabled(); void setEnabled(boolean enabled); String getRegion(); void setRegion(final String region); static final String CONFIG_PREFIX; }