@Test public void test_getAccessTypes() { Set<String> accessTypes = _validator.getAccessTypes((RangerServiceDef)null); Assert.assertTrue(accessTypes.isEmpty()); RangerServiceDef serviceDef = mock(RangerServiceDef.class); when(serviceDef.getAccessTypes()).thenReturn(null); accessTypes = _validator.getAccessTypes(serviceDef); Assert.assertTrue(accessTypes.isEmpty()); List<RangerAccessTypeDef> accessTypeDefs = new ArrayList<>(); when(serviceDef.getAccessTypes()).thenReturn(accessTypeDefs); accessTypes = _validator.getAccessTypes(serviceDef); Assert.assertTrue(accessTypes.isEmpty()); accessTypeDefs.add(null); accessTypes = _validator.getAccessTypes(serviceDef); Assert.assertTrue(accessTypes.isEmpty()); String[] names = new String[] { null, "", "a", " ", "b ", " ", " C", " D " }; accessTypeDefs.addAll(_utils.createAccessTypeDefs(names)); accessTypes = _validator.getAccessTypes(serviceDef); Assert.assertEquals(4, accessTypes.size()); Assert.assertTrue(accessTypes.contains("a")); Assert.assertTrue(accessTypes.contains("b ")); Assert.assertTrue(accessTypes.contains(" C")); Assert.assertTrue(accessTypes.contains(" D ")); }
Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<>(); 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); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; }
RangerValidator { Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<>(); 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); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; } }
RangerValidator { Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<>(); 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); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); }
RangerValidator { Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<>(); 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); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures); }
RangerValidator { Set<String> getAccessTypes(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getAccessTypes(" + serviceDef + ")"); } Set<String> accessTypes = new HashSet<>(); 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); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getAccessTypes(" + serviceDef + "): " + accessTypes); } return accessTypes; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures);  }