### Question:
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); void validate(Long id, Action action);  }### Answer:
@Test public void test_getRequiredParameters() { Set<String> parameters = _validator.getRequiredParameters(null); assertNotNull(parameters); assertTrue(parameters.isEmpty()); RangerServiceDef serviceDef = mock(RangerServiceDef.class); when(serviceDef.getConfigs()).thenReturn(null); parameters = _validator.getRequiredParameters(null); assertNotNull(parameters); assertTrue(parameters.isEmpty()); List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceDef.RangerServiceConfigDef>(); when(serviceDef.getConfigs()).thenReturn(configs); parameters = _validator.getRequiredParameters(null); assertNotNull(parameters); 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); assertTrue("result does not contain: param2", parameters.contains("param2")); assertTrue("result does not contain: param3", parameters.contains("param3")); }