@SuppressWarnings("serial") @Test public void testMultipleNestedInvalidFieldNames() { final String invalidCustomEntityId = "invalidCustomEntity6"; EntityBody invalidCustomEntity = new EntityBody() { { put("ID", invalidCustomEntityId); put("FSCommand = DEL", "goodFieldValue"); put("nestedField", new HashMap<String, Object>() { { put("goodFieldName1", "goodFieldValue"); put("bad\u0000FieldName2", "goodFieldValue"); put("goodFieldName2", new LinkedList<HashMap<String, Object>>() { { add(new HashMap<String, Object>() { { put("goodSubFieldName1", "goodFieldValue"); } }); add(new HashMap<String, Object>() { { put("goodSubFieldName2", "goodFieldValue"); put("bad\\x00FieldName3", new HashMap[] { new HashMap<String, Object>() { { put("goodSubFieldName", "goodFieldValue"); } }, new HashMap<String, Object>() { { put("goodSubFieldName3", "goodFieldValue"); put("bad\u007FFieldName4", "goodFieldValue"); } } }); } }); } }); } }); } }; List<ValidationError> validationErrors = customEntityValidator.validate(invalidCustomEntity); Assert.assertEquals("Should be 4 validation errors", 4, validationErrors.size()); ValidationError ve1 = new ValidationError(ValidationError.ErrorType.INVALID_FIELD_NAME, "FSCommand = DEL", "FSCommand = DEL", null); ValidationError ve2 = new ValidationError(ValidationError.ErrorType.INVALID_FIELD_NAME, "bad\u0000FieldName2", "bad\u0000FieldName2", null); ValidationError ve3 = new ValidationError(ValidationError.ErrorType.INVALID_FIELD_NAME, "bad\\x00FieldName3", "bad\\x00FieldName3", null); ValidationError ve4 = new ValidationError(ValidationError.ErrorType.INVALID_FIELD_NAME, "bad\u007FFieldName4", "bad\u007FFieldName4", null); assertValidationErrorIsInList(validationErrors, ve1); assertValidationErrorIsInList(validationErrors, ve2); assertValidationErrorIsInList(validationErrors, ve3); assertValidationErrorIsInList(validationErrors, ve4); }
public List<ValidationError> validate(EntityBody entityBody) { List<ValidationError> errorList = new ArrayList<ValidationError>(); if (!entityBody.isEmpty()) { validate(entityBody, errorList); } return errorList; }
CustomEntityValidator { public List<ValidationError> validate(EntityBody entityBody) { List<ValidationError> errorList = new ArrayList<ValidationError>(); if (!entityBody.isEmpty()) { validate(entityBody, errorList); } return errorList; } }
CustomEntityValidator { public List<ValidationError> validate(EntityBody entityBody) { List<ValidationError> errorList = new ArrayList<ValidationError>(); if (!entityBody.isEmpty()) { validate(entityBody, errorList); } return errorList; }  }
CustomEntityValidator { public List<ValidationError> validate(EntityBody entityBody) { List<ValidationError> errorList = new ArrayList<ValidationError>(); if (!entityBody.isEmpty()) { validate(entityBody, errorList); } return errorList; }  List<ValidationError> validate(EntityBody entityBody); }
CustomEntityValidator { public List<ValidationError> validate(EntityBody entityBody) { List<ValidationError> errorList = new ArrayList<ValidationError>(); if (!entityBody.isEmpty()) { validate(entityBody, errorList); } return errorList; }  List<ValidationError> validate(EntityBody entityBody);  }