### Question:
RangerPolicyValidator extends RangerValidator { boolean isValidItemAccesses(List<RangerPolicyItemAccess> accesses, List<ValidationFailureDetails> failures, RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerPolicyValidator.isValid(%s, %s, %s)", accesses, failures, serviceDef)); } boolean valid = true; if (CollectionUtils.isEmpty(accesses)) { LOG.debug("policy item accesses collection was null/empty!"); } else { Set<String> accessTypes = getAccessTypes(serviceDef); for (RangerPolicyItemAccess access : accesses) { if (access == null) { ValidationErrorCode error = ValidationErrorCode.POLICY_VALIDATION_ERR_NULL_POLICY_ITEM_ACCESS; failures.add(new ValidationFailureDetailsBuilder() .field("policy item access") .isMissing() .becauseOf(error.getMessage()) .errorCode(error.getErrorCode()) .build()); valid = false; } else { valid = isValidPolicyItemAccess(access, failures, accessTypes) && valid; } } } if(LOG.isDebugEnabled()) { LOG.debug(String.format("<== RangerPolicyValidator.isValid(%s, %s): %s", accesses, failures, serviceDef, valid)); } return valid; } RangerPolicyValidator(ServiceStore store); void validate(RangerPolicy policy, Action action, boolean isAdmin);  }### Answer:
@Test public void test_isValidItemAccesses_happyPath() { Object[][] data = new Object[][] { { "a", null }, { "b", true }, { "c", true }, }; List<RangerPolicyItemAccess> accesses = _utils.createItemAccess(data); _serviceDef = _utils.createServiceDefWithAccessTypes(new String[] { "a", "b", "c", "d" }); assertTrue(_validator.isValidItemAccesses(accesses, _failures, _serviceDef)); assertTrue(_failures.isEmpty()); }
@Test public void test_isValidItemAccesses_failure() { List<RangerPolicyItemAccess> accesses = new ArrayList<RangerPolicyItemAccess>(); accesses.add(null); _failures.clear(); assertFalse(_validator.isValidItemAccesses(accesses, _failures, _serviceDef)); _utils.checkFailureForMissingValue(_failures, "policy item access"); Object[][] data = new Object[][] { { "a", null }, { null, null }, { "c", true }, }; accesses = _utils.createItemAccess(data); _serviceDef = _utils.createServiceDefWithAccessTypes(new String[] { "a", "b", "c", "d" }); _failures.clear(); assertFalse(_validator.isValidItemAccesses(accesses, _failures, _serviceDef)); }