@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); Assert.assertNull(_validator.getPolicy(1L)); Assert.assertNull(_validator.getPolicy(2L)); Assert.assertTrue(_validator.getPolicy(3L) != null); }
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; }
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; } }
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); protected  RangerValidator(RoleStore roleStore); }
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); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures); }
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); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures);  }