### Question:
RangerValidator { Map<String, String> getValidationRegExes(RangerServiceDef serviceDef) { if (serviceDef == null || CollectionUtils.isEmpty(serviceDef.getResources())) { return new HashMap<String, String>(); } else { Map<String, String> result = new HashMap<String, String>(); for (RangerResourceDef resourceDef : serviceDef.getResources()) { if (resourceDef == null) { LOG.warn("A resource def in resource def collection is null"); } else { String name = resourceDef.getName(); String regEx = resourceDef.getValidationRegEx(); if (StringUtils.isBlank(name)) { LOG.warn("resource name is null/empty/blank"); } else if (StringUtils.isBlank(regEx)) { LOG.debug("validation regex is null/empty/blank"); } else { result.put(name, regEx); } } } return result; } } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public void test_getValidationRegExes() { Map<String, String> regExMap = _validator.getValidationRegExes((RangerServiceDef)null); assertTrue(regExMap.isEmpty()); RangerServiceDef serviceDef = mock(RangerServiceDef.class); when(serviceDef.getResources()).thenReturn(null); regExMap = _validator.getValidationRegExes(serviceDef); assertTrue(regExMap.isEmpty()); List<RangerResourceDef> resourceDefs = new ArrayList<RangerResourceDef>(); when(serviceDef.getResources()).thenReturn(resourceDefs); regExMap = _validator.getValidationRegExes(serviceDef); assertTrue(regExMap.isEmpty()); resourceDefs.add(null); regExMap = _validator.getValidationRegExes(serviceDef); assertTrue(regExMap.isEmpty()); String[][] data = { { "a", null }, null, { "b", "regex1" }, { "c", "" }, { "d", "regex2" }, { "e", " " }, { "f", "regex3" }, }; resourceDefs.addAll(_utils.createResourceDefsWithRegEx(data)); regExMap = _validator.getValidationRegExes(serviceDef); assertEquals(3, regExMap.size()); assertEquals("regex1", regExMap.get("b")); assertEquals("regex2", regExMap.get("d")); assertEquals("regex3", regExMap.get("f")); }