### Question:
RangerValidator { Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<String>(); if (serviceDef == null) { LOG.warn("serviceDef passed in was null!"); } else if (CollectionUtils.isEmpty(serviceDef.getAccessTypes())) { LOG.warn("AccessTypeDef collection on serviceDef was null!"); } else { for (RangerAccessTypeDef accessTypeDef : serviceDef.getAccessTypes()) { if (accessTypeDef == null) { LOG.warn("Access type def was null!"); } else { String accessType = accessTypeDef.getName(); if (StringUtils.isBlank(accessType)) { LOG.warn("Access type def name was null/empty/blank!"); } else { accessTypes.add(accessType.toLowerCase()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public void test_getAccessTypes() { Set<String> accessTypes = _validator.getAccessTypes((RangerServiceDef)null); assertTrue(accessTypes.isEmpty()); RangerServiceDef serviceDef = mock(RangerServiceDef.class); when(serviceDef.getAccessTypes()).thenReturn(null); accessTypes = _validator.getAccessTypes(serviceDef); assertTrue(accessTypes.isEmpty()); List<RangerAccessTypeDef> accessTypeDefs = new ArrayList<RangerServiceDef.RangerAccessTypeDef>(); when(serviceDef.getAccessTypes()).thenReturn(accessTypeDefs); accessTypes = _validator.getAccessTypes(serviceDef); assertTrue(accessTypes.isEmpty()); accessTypeDefs.add(null); accessTypes = _validator.getAccessTypes(serviceDef); assertTrue(accessTypes.isEmpty()); String[] names = new String[] { null, "", "a", " ", "b ", " ", " C", " D " }; accessTypeDefs.addAll(_utils.createAccessTypeDefs(names)); accessTypes = _validator.getAccessTypes(serviceDef); assertEquals(4, accessTypes.size()); assertTrue(accessTypes.contains("a")); assertTrue(accessTypes.contains("b ")); assertTrue(accessTypes.contains(" c")); assertTrue(accessTypes.contains(" d ")); }