### Question:
RangerValidator { List<RangerPolicy> getPolicies(final String serviceName, final String policyName) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getPolicies(" + serviceName + ", " + policyName + ")"); } List<RangerPolicy> policies = null; try { SearchFilter filter = new SearchFilter(); if (StringUtils.isNotBlank(policyName)) { filter.setParam(SearchFilter.POLICY_NAME, policyName); } filter.setParam(SearchFilter.SERVICE_NAME, serviceName); policies = _store.getPolicies(filter); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug("<== RangerValidator.getPolicies(" + serviceName + ", " + policyName + "): count[" + count + "], " + policies); } return policies; } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public void test_getPolicies() throws Exception { String policyName = "aPolicy"; String serviceName = "aService"; SearchFilter filter = new SearchFilter(); filter.setParam(SearchFilter.POLICY_NAME, policyName); filter.setParam(SearchFilter.SERVICE_NAME, serviceName); when(_store.getPolicies(filter)).thenReturn(null); List<RangerPolicy> result = _validator.getPolicies(serviceName, policyName); verify(_store).getPolicies(filter); assertNull(result); when(_store.getPolicies(filter)).thenThrow(new Exception()); result = _validator.getPolicies(serviceName, policyName); assertNull(result); filter = new SearchFilter(); filter.setParam(SearchFilter.SERVICE_NAME, serviceName); List<RangerPolicy> policies = new ArrayList<RangerPolicy>(); RangerPolicy policy = mock(RangerPolicy.class); policies.add(policy); when(_store.getPolicies(filter)).thenReturn(policies); for (String aName : new String[]{ null, "", " "}) { result = _validator.getPolicies(serviceName, aName); assertTrue(result.iterator().next() == policy); } }