GroupExistanceVerifierChainLink extends DefaultVerifierChainLink<T> { @Override protected void verifyLink(final T resource) { List<String> groups = sessionService.getGroups(); User user = sessionService.getUser(); if (groups.isEmpty()) { LOG.info(MessageFormat.format("There is no group for user:{0}", user.getLogin())); NoGroupForUserException e = new NoGroupForUserException("There is no group for user"); e.setUser(user); throw e; } }  void setSessionService(final SessionService sessionService);  }
@Test(expected = NoGroupForUserException.class) public void testVerifyLink() throws Exception { Department resource = null; List<String> groups = Collections.emptyList(); String login = "developers"; User user = new User(); user.setLogin(login); when(sessionService.getGroups()).thenReturn(groups); when(sessionService.getUser()).thenReturn(user); unit.verify(resource); verify(sessionService).getGroups(); verify(sessionService).getUser(); }