@Test public void test_getRequiredParameters() { Set<String> parameters = _validator.getRequiredParameters(null); Assert.assertNotNull(parameters); Assert.assertTrue(parameters.isEmpty()); RangerServiceDef serviceDef = mock(RangerServiceDef.class); when(serviceDef.getConfigs()).thenReturn(null); parameters = _validator.getRequiredParameters(null); Assert.assertNotNull(parameters); Assert.assertTrue(parameters.isEmpty()); List<RangerServiceConfigDef> configs = new ArrayList<>(); when(serviceDef.getConfigs()).thenReturn(configs); parameters = _validator.getRequiredParameters(null); Assert.assertNotNull(parameters); Assert.assertTrue(parameters.isEmpty()); Object[][] input = new Object[][] { { "param1", false }, { "param2", true }, { "param3", true }, { "param4", false }, }; configs = _utils.createServiceConditionDefs(input); when(serviceDef.getConfigs()).thenReturn(configs); parameters = _validator.getRequiredParameters(serviceDef); Assert.assertTrue("result does not contain: param2", parameters.contains("param2")); Assert.assertTrue("result does not contain: param3", parameters.contains("param3")); }
Set<String> getRequiredParameters(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getRequiredParameters(" + serviceDef + ")"); } Set<String> result; if (serviceDef == null) { result = Collections.emptySet(); } else { List<RangerServiceConfigDef> configs = serviceDef.getConfigs(); if (CollectionUtils.isEmpty(configs)) { result = Collections.emptySet(); } else { result = new HashSet<String>(configs.size()); for (RangerServiceConfigDef configDef : configs) { if (configDef.getMandatory()) { result.add(configDef.getName()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getRequiredParameters(" + serviceDef + "): " + result); } return result; }
RangerValidator { Set<String> getRequiredParameters(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getRequiredParameters(" + serviceDef + ")"); } Set<String> result; if (serviceDef == null) { result = Collections.emptySet(); } else { List<RangerServiceConfigDef> configs = serviceDef.getConfigs(); if (CollectionUtils.isEmpty(configs)) { result = Collections.emptySet(); } else { result = new HashSet<String>(configs.size()); for (RangerServiceConfigDef configDef : configs) { if (configDef.getMandatory()) { result.add(configDef.getName()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getRequiredParameters(" + serviceDef + "): " + result); } return result; } }
RangerValidator { Set<String> getRequiredParameters(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getRequiredParameters(" + serviceDef + ")"); } Set<String> result; if (serviceDef == null) { result = Collections.emptySet(); } else { List<RangerServiceConfigDef> configs = serviceDef.getConfigs(); if (CollectionUtils.isEmpty(configs)) { result = Collections.emptySet(); } else { result = new HashSet<String>(configs.size()); for (RangerServiceConfigDef configDef : configs) { if (configDef.getMandatory()) { result.add(configDef.getName()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getRequiredParameters(" + serviceDef + "): " + result); } return result; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); }
RangerValidator { Set<String> getRequiredParameters(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getRequiredParameters(" + serviceDef + ")"); } Set<String> result; if (serviceDef == null) { result = Collections.emptySet(); } else { List<RangerServiceConfigDef> configs = serviceDef.getConfigs(); if (CollectionUtils.isEmpty(configs)) { result = Collections.emptySet(); } else { result = new HashSet<String>(configs.size()); for (RangerServiceConfigDef configDef : configs) { if (configDef.getMandatory()) { result.add(configDef.getName()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getRequiredParameters(" + serviceDef + "): " + result); } return result; } 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> getRequiredParameters(RangerServiceDef serviceDef) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getRequiredParameters(" + serviceDef + ")"); } Set<String> result; if (serviceDef == null) { result = Collections.emptySet(); } else { List<RangerServiceConfigDef> configs = serviceDef.getConfigs(); if (CollectionUtils.isEmpty(configs)) { result = Collections.emptySet(); } else { result = new HashSet<String>(configs.size()); for (RangerServiceConfigDef configDef : configs) { if (configDef.getMandatory()) { result.add(configDef.getName()); } } } } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getRequiredParameters(" + serviceDef + "): " + result); } return result; } 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);  }