### Question:
ValidationUtil { @SuppressWarnings("unchecked") public static ValidationResult validate(ValidationModel validateModel) { Objects.requireNonNull(validateModel); ValidationResult validationResult = new ValidationResult(); if (skipValidationForTesting) { return validationResult; } if (validateModel.getDataObject() == null && validateModel.isAcceptNull() == false) { RuleResult ruleResult = new RuleResult(); ruleResult.setMessage("The whole data object is null."); ruleResult.setValidationRule("Don't allow null object"); validationResult.getRuleResults().add(ruleResult); } else { if (validateModel.getDataObject() != null) { if (validateModel.getDataObject() instanceof Collection) { ((Collection) validateModel.getDataObject()).stream().forEach((dataObject) -> { validationResult.getRuleResults().addAll(validate(ValidationModel.copy(validateModel, dataObject)).getRuleResults()); }); } else { if (validateModel.getApplyDefaults() && validateModel.getDataObject() instanceof BaseEntity) { BaseEntity baseEntity = (BaseEntity) validateModel.getDataObject(); baseEntity.applyDefaultValues(); } validationResult.getRuleResults().addAll(validateFields(validateModel, validateModel.getDataObject().getClass(), null, null)); } } } return validationResult; } private  ValidationUtil(); static boolean isValid(ValidationModel validateModel); @SuppressWarnings("unchecked") static ValidationResult validate(ValidationModel validateModel); static void setSkipValidationForTesting(boolean aSkipValidationForTesting);  }### Answer:
@Test public void testValidate() { System.out.println("validate"); UserTypeCode userTypeCode = new UserTypeCode(); userTypeCode.setCode("Test"); userTypeCode.setDescription("Test Description"); ValidationModel validateModel = new ValidationModel(userTypeCode); validateModel.setConsumeFieldsOnly(true); ValidationResult result = ValidationUtil.validate(validateModel); System.out.println("Any Valid Consume: " + result.toString()); if (result.valid() == false) { fail("Failed validation when it was expected to pass."); } System.out.println("-------------------------------"); validateModel = new ValidationModel(userTypeCode); result = ValidationUtil.validate(validateModel); System.out.println("Failed: " + result.toString()); validateModel = new ValidationModel(userTypeCode); validateModel.setSantize(true); result = ValidationUtil.validate(validateModel); if (result.valid() == true) { fail("Failed validation when it was expected to pass"); } else { System.out.println("Test Passed"); } System.out.println("-------------------------------"); validateModel = new ValidationModel(userTypeCode); validateModel.setDataObject(null); validateModel.setAcceptNull(true); result = ValidationUtil.validate(validateModel); if (result.valid() == false) { fail("Failed validation when it was expected to pass"); } else { System.out.println("Test Passed"); } System.out.println("-------------------------------"); }