@Test public void execute() { CommandFunction commandFunction = mock(CommandFunction.class); SendMessage sendMessage = mock(SendMessage.class); Message response = mock(Message.class); when(commandFunction.execute(any())).thenReturn(response); RespondingCommand respondingCommand = new RespondingCommand( sendMessage, commandFunction ); CommandExecution commandExecution = mock(CommandExecution.class); when(commandExecution.getSender()).thenReturn(mock(Sender.class)); respondingCommand.execute(commandExecution); verify(sendMessage).to(any(), same(response)); }
@Override public void execute(CommandExecution execution) { sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); }
RespondingCommand implements Command { @Override public void execute(CommandExecution execution) { sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); } }
RespondingCommand implements Command { @Override public void execute(CommandExecution execution) { sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); }  }
RespondingCommand implements Command { @Override public void execute(CommandExecution execution) { sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); }  @Override void execute(CommandExecution execution); }
RespondingCommand implements Command { @Override public void execute(CommandExecution execution) { sendMessage.to(execution.getSender().getId(), commandFunction.execute(execution)); }  @Override void execute(CommandExecution execution);  }