CommandParser { public void sendFile(final User user, final FileToSend file) throws CommandException { controller.sendFile(user, file); final FileSender fileSend = tList.addFileSender(user, file); ui.showTransfer(fileSend); final String size = Tools.byteToString(file.length()); msgController.showSystemMessage(coreMessages.getMessage( "core.command.send.systemMessage.sendingFile", file.getName(), fileSend.getId(), size, user.getNick())); } CommandParser(final Controller controller, final UserInterface ui, final Settings settings,
                         final CoreMessages coreMessages); void fixTopic(final String newTopic); void sendFile(final User user, final FileToSend file); void cancelFileTransfer(final FileTransfer fileTransfer); void showCommands(); void parse(final String line);  }
@Test public void sendFileShouldSendUsingControllerAndAddToTransferListAndShowFileTransfer() throws CommandException { final User user = new User("User", 123456); final FileToSend file = new FileToSend(new File("")); final FileSender fileSender = mock(FileSender.class); when(transferList.addFileSender(any(User.class), any(FileToSend.class))).thenReturn(fileSender); parser.sendFile(user, file); verify(controller).sendFile(user, file); verify(transferList).addFileSender(user, file); verify(userInterface).showTransfer(fileSender); }
@Test public void sendFileShouldShowSystemMessage() throws CommandException { final User user = new User("Kelly", 123456); final FileToSend file = mock(FileToSend.class); final FileSender fileSender = mock(FileSender.class); when(file.getName()).thenReturn("picture.png"); when(file.length()).thenReturn(1024 * 1024 * 54L); when(fileSender.getId()).thenReturn(2); when(transferList.addFileSender(any(User.class), any(FileToSend.class))).thenReturn(fileSender); parser.sendFile(user, file); verify(messageController).showSystemMessage("Trying to send the file picture.png (#2) [54.00MB] to Kelly"); }