@Test(expected = ValidationException.class) public void testLengthFailureValidate() { final HashMap<String, Serializable> map = new HashMap<String, Serializable>(); map.put("key", "1234567890123"); sut = new MapParameterLengthValidator("key", SMALL_MAX_TEST_LENGTH, "Length is invalid"); sut.validate(map, new HashMap<String, String>()); }
public void validate(final Map<String, Serializable> map, final Map<String, String> errors) { if (map.get(key) != null && (map.get(key) instanceof String) && (((String) map.get(key)).length() > length)) { errors.put(key, message); } if (valDecorator != null) { valDecorator.validate(map, errors); } else if (!errors.isEmpty()) { ValidationException ve = new ValidationException(); for (String errorKey : errors.keySet()) { ve.addError(errorKey, errors.get(errorKey)); } throw ve; } }
MapParameterLengthValidator implements MapParameterValidatorDecorator { public void validate(final Map<String, Serializable> map, final Map<String, String> errors) { if (map.get(key) != null && (map.get(key) instanceof String) && (((String) map.get(key)).length() > length)) { errors.put(key, message); } if (valDecorator != null) { valDecorator.validate(map, errors); } else if (!errors.isEmpty()) { ValidationException ve = new ValidationException(); for (String errorKey : errors.keySet()) { ve.addError(errorKey, errors.get(errorKey)); } throw ve; } } }
MapParameterLengthValidator implements MapParameterValidatorDecorator { public void validate(final Map<String, Serializable> map, final Map<String, String> errors) { if (map.get(key) != null && (map.get(key) instanceof String) && (((String) map.get(key)).length() > length)) { errors.put(key, message); } if (valDecorator != null) { valDecorator.validate(map, errors); } else if (!errors.isEmpty()) { ValidationException ve = new ValidationException(); for (String errorKey : errors.keySet()) { ve.addError(errorKey, errors.get(errorKey)); } throw ve; } } MapParameterLengthValidator(final String inKey, final int inValLength, final String inMessage); }
MapParameterLengthValidator implements MapParameterValidatorDecorator { public void validate(final Map<String, Serializable> map, final Map<String, String> errors) { if (map.get(key) != null && (map.get(key) instanceof String) && (((String) map.get(key)).length() > length)) { errors.put(key, message); } if (valDecorator != null) { valDecorator.validate(map, errors); } else if (!errors.isEmpty()) { ValidationException ve = new ValidationException(); for (String errorKey : errors.keySet()) { ve.addError(errorKey, errors.get(errorKey)); } throw ve; } } MapParameterLengthValidator(final String inKey, final int inValLength, final String inMessage); void setMapParameterValidatorDecorator(
            final MapParameterValidatorDecorator inDecorated); void validate(final Map<String, Serializable> map,
            final Map<String, String> errors); }
MapParameterLengthValidator implements MapParameterValidatorDecorator { public void validate(final Map<String, Serializable> map, final Map<String, String> errors) { if (map.get(key) != null && (map.get(key) instanceof String) && (((String) map.get(key)).length() > length)) { errors.put(key, message); } if (valDecorator != null) { valDecorator.validate(map, errors); } else if (!errors.isEmpty()) { ValidationException ve = new ValidationException(); for (String errorKey : errors.keySet()) { ve.addError(errorKey, errors.get(errorKey)); } throw ve; } } MapParameterLengthValidator(final String inKey, final int inValLength, final String inMessage); void setMapParameterValidatorDecorator(
            final MapParameterValidatorDecorator inDecorated); void validate(final Map<String, Serializable> map,
            final Map<String, String> errors);  }