@Test public void test_getService_byId() throws Exception { when(_store.getService(1L)).thenReturn(null); when(_store.getService(2L)).thenThrow(new Exception()); RangerService service = mock(RangerService.class); when(_store.getService(3L)).thenReturn(service); Assert.assertNull(_validator.getService(1L)); Assert.assertNull(_validator.getService(2L)); Assert.assertTrue(_validator.getService(3L) != null); }
RangerService getService(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getService(" + id + ")"); } RangerService result = null; try { result = _store.getService(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getService(" + id + "): " + result); } return result; }
RangerValidator { RangerService getService(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getService(" + id + ")"); } RangerService result = null; try { result = _store.getService(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getService(" + id + "): " + result); } return result; } }
RangerValidator { RangerService getService(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getService(" + id + ")"); } RangerService result = null; try { result = _store.getService(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getService(" + id + "): " + result); } return result; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); }
RangerValidator { RangerService getService(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getService(" + id + ")"); } RangerService result = null; try { result = _store.getService(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getService(" + 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 { RangerService getService(Long id) { if(LOG.isDebugEnabled()) { LOG.debug("==> RangerValidator.getService(" + id + ")"); } RangerService result = null; try { result = _store.getService(id); } catch (Exception e) { LOG.debug("Encountred exception while retrieving service from service store!", e); } if(LOG.isDebugEnabled()) { LOG.debug("<== RangerValidator.getService(" + 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);  }