@Test public void sendChatMessageShouldSendMessageUsingNetworkMessages() throws CommandException { doReturn(true).when(controller).isConnected(); controller.sendChatMessage("the message"); verify(networkMessages).sendChatMessage("the message"); }
/** * Tests sendChatMessage(). * * Expects: 16899115!MSG#Christian:[-15987646]Some chat message * * @throws CommandException In case the message could not be sent. */ @Test public void testSendChatMessage() throws CommandException { final String msg = "Some chat message"; messages.sendChatMessage(msg); verify(service).sendMessageToAllUsers(createMessage("MSG") + "[" + settings.getOwnColor() + "]" + msg); }
/** * Sends a chat message over the network, to all the other users. * * @param msg The message to send. * @throws CommandException If there is no connection to the network, * or the application user is away, * or the message is empty, * or the message is too long. */ public void sendChatMessage(final String msg) throws CommandException { if (!isConnected()) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.notConnected")); } else if (me.isAway()) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.meIsAway")); } else if (msg.trim().length() == 0) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.emptyMessage")); } else if (Tools.getBytes(msg) > Constants.MESSAGE_MAX_BYTES) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.messageTooLong", Constants.MESSAGE_MAX_BYTES)); } else { networkMessages.sendChatMessage(msg); } }
/** * Sends a chat message over the network, to all the other users. * * @param msg The message to send. * @throws CommandException If there is no connection to the network, * or the application user is away, * or the message is empty, * or the message is too long. */ public void sendChatMessage(final String msg) throws CommandException { if (!isConnected()) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.notConnected")); } else if (me.isAway()) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.meIsAway")); } else if (msg.trim().length() == 0) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.emptyMessage")); } else if (Tools.getBytes(msg) > Constants.MESSAGE_MAX_BYTES) { throw new CommandException(coreMessages.getMessage("core.chatMessage.error.messageTooLong", Constants.MESSAGE_MAX_BYTES)); } else { networkMessages.sendChatMessage(msg); } }