### Question:
RangerValidator { RangerPolicy getPolicy(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getPolicy(" + id + ")"); } RangerPolicy result = null; try { result = _store.getPolicy(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving policy from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getPolicy(" + id + "): " + result); } return result; } protected  RangerValidator(ServiceStore store); void validate(Long id, Action action);  }### Answer:
@Test public void test_getPolicy() throws Exception { when(_store.getPolicy(1L)).thenReturn(null); when(_store.getPolicy(2L)).thenThrow(new Exception()); RangerPolicy policy = mock(RangerPolicy.class); when(_store.getPolicy(3L)).thenReturn(policy); assertNull(_validator.getPolicy(1L)); assertNull(_validator.getPolicy(2L)); assertTrue(_validator.getPolicy(3L) != null); }