@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"); }
/** * Sends a file to a user. * * @param user The user to send to. * @param file The file to send to the user. * @throws CommandException If there was a problem sending the file. */ 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())); }
/** * Sends a file to a user. * * @param user The user to send to. * @param file The file to send to the user. * @throws CommandException If there was a problem sending the file. */ 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())); }