DefaultMessageResponder implements MessageResponder { @Override public void clientInfo(final int userCode, final String client, final long timeSinceLogon, final String operatingSystem, final int privateChatPort, final int tcpChatPort) { final User user = controller.getUser(userCode); if (user != null) { user.setClient(client); user.setLogonTime(System.currentTimeMillis() - timeSinceLogon); user.setOperatingSystem(operatingSystem); user.setPrivateChatPort(privateChatPort); user.setTcpChatPort(tcpChatPort); } else { LOG.severe("Could not find user: %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 clientInfoShouldFillDetailsOnKnownUser() { setUpExistingUser(); responder.clientInfo(100, "swing", 150, "linux", 4000, 5000); final long logonTime = System.currentTimeMillis() - 150; assertTrue(user.getLogonTime() <= logonTime && user.getLogonTime() > logonTime - 10); assertEquals("swing", user.getClient()); assertEquals("linux", user.getOperatingSystem()); assertEquals(4000, user.getPrivateChatPort()); assertEquals(5000, user.getTcpChatPort()); }
@Test public void clientInfoShouldDoNothingOnUnknownUser() { setUpUnknownUser(); responder.clientInfo(100, "swing", 150, "linux", 4000, 5000); assertEquals(0, user.getLogonTime()); assertEquals("<unknown>", user.getClient()); assertEquals("<unknown>", user.getOperatingSystem()); assertEquals(0, user.getPrivateChatPort()); assertEquals(0, user.getTcpChatPort()); }