### Question:
RangerValidator { List<RangerPolicy> getPoliciesForResourceSignature(String serviceName, String policySignature) { if(LOG.isDebugEnabled()) { LOG.debug(String.format("==> RangerValidator.getPoliciesForResourceSignature(%s, %s)", serviceName, policySignature)); } List<RangerPolicy> policies = null; try { policies = _store.getPoliciesByResourceSignature(serviceName, policySignature, true); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policies from service store!", e); } if(LOG.isDebugEnabled()) { int count = policies == null ? 0 : policies.size(); LOG.debug(String.format("<== RangerValidator.getPoliciesForResourceSignature(%s, %s): count[%d], %s", serviceName, policySignature, count, policies)); } return policies; } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public final void test_getPoliciesForResourceSignature() throws Exception { String hexSignature = "aSignature"; String serviceName = "service-name"; boolean isPolicyEnabled = true; when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenReturn(null); assertNull(_validator.getPoliciesForResourceSignature(serviceName, hexSignature)); when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenThrow(new Exception()); assertNull(_validator.getPoliciesForResourceSignature(serviceName, hexSignature)); hexSignature = "anotherSignature"; List<RangerPolicy> policies = new ArrayList<RangerPolicy>(); RangerPolicy policy1 = mock(RangerPolicy.class); policies.add(policy1); RangerPolicy policy2 = mock(RangerPolicy.class); policies.add(policy2); when(_store.getPoliciesByResourceSignature(serviceName, hexSignature, isPolicyEnabled)).thenReturn(policies); List<RangerPolicy> result = _validator.getPoliciesForResourceSignature(serviceName, hexSignature); assertTrue(result.contains(policy1) && result.contains(policy2)); }