DefaultMessageResponder implements MessageResponder { @Override public void userLogOff(final int userCode) { final User user = controller.getUser(userCode); if (user != null) { final String logOffMessage = coreMessages.getMessage("core.network.systemMessage.userLogOff", user.getNick()); controller.removeUser(user, logOffMessage); msgController.showSystemMessage(logOffMessage); } else { LOG.severe("User is unknown - ignoring logoff. userCode=%s", userCode); } } DefaultMessageResponder(final Controller controller, final UserInterface ui, final Settings settings,
                                   final CoreMessages coreMessages); @Override void messageArrived(final int userCode, final String msg, final int color); @Override void userLogOff(final int userCode); @Override void userLogOn(final User newUser); @Override void topicChanged(final int userCode, final String newTopic, final String nick, final long time); @Override void userExposing(final User user); @Override void meLogOn(final String ipAddress); @Override void writingChanged(final int userCode, final boolean writing); @Override void awayChanged(final int userCode, final boolean away, final String awayMsg); @Override void meIdle(final String ipAddress); @Override void userIdle(final int userCode, final String ipAddress); @Override void topicRequested(); @Override void nickCrash(); @Override void exposeRequested(); @Override void nickChanged(final int userCode, final String newNick); @Override void fileSend(final int userCode, final long byteSize, final String fileName, final String user, final int fileHash); @Override void fileSendAborted(final int userCode, final String fileName, final int fileHash); @Override void fileSendAccepted(final int userCode, final String fileName, final int fileHash, final int port); @Override void clientInfo(final int userCode, final String client, final long timeSinceLogon,
                           final String operatingSystem, final int privateChatPort, final int tcpChatPort);  }
@Test public void userLogOffShouldDoNothingIfUserIsUnknown() { setUpUnknownUser(); responder.userLogOff(100); verifyZeroInteractions(messageController); verify(controller, never()).removeUser(any(User.class), anyString()); }
@Test public void userLogOffShouldRemoveUserAndShowSystemMessage() { setUpExistingUser(); responder.userLogOff(100); verify(messageController).showSystemMessage("Tester logged off"); verify(controller).removeUser(user, "Tester logged off"); }