NetworkMessages { public void sendPrivateMessage(final String privMsg, final User user) throws CommandException { final String msg = createMessage(PRIVMSG) + "(" + user.getCode() + ")" + "[" + settings.getOwnColor() + "]" + privMsg; final boolean sent = networkService.sendMessageToUser(msg, user); if (!sent) { checkNetwork(); notifyUser("Failed to send private message to " + user.getNick() + ": " + privMsg); } } NetworkMessages(final NetworkService networkService, final Settings settings); void sendIdleMessage(); void sendTopicChangeMessage(final Topic topic); void sendTopicRequestedMessage(final Topic topic); void sendAwayMessage(final String awayMsg); void sendBackMessage(); void sendChatMessage(final String chatMsg); void sendLogonMessage(); void sendLogoffMessage(); void sendExposeMessage(); void sendExposingMessage(); void sendGetTopicMessage(); void sendWritingMessage(); void sendStoppedWritingMessage(); void sendNickMessage(final String newNick); void sendNickCrashMessage(final String crashNick); void sendFileAbort(final User user, final int fileHash, final String fileName); void sendFileAccept(final User user, final int port,
            final int fileHash, final String fileName); void sendFile(final User user, final FileToSend file); void sendClient(); void sendPrivateMessage(final String privMsg, final User user);  }
@Test public void testSendPrivateMessage() throws CommandException { final String privmsg = "this is a private message"; final String userIP = "192.168.5.155"; final int userPort = 12345; final int userCode = 435435; final String message = "(" + userCode + ")" + "[" + settings.getOwnColor() + "]" + privmsg; final User user = new User("TestUser", userCode); user.setPrivateChatPort(userPort); user.setIpAddress(userIP); messages.sendPrivateMessage(privmsg, user); verify(service).sendMessageToUser(createMessage("PRIVMSG") + message, user); }