@Override public void redo() throws Exception { command.execute(); command.undo(); command.redo(); verify(container, times(2)).addCard(card); }
@Override public void undo() throws Exception { assertThat(command.canUndo(), is(false)); command.execute(); assertThat(command.canUndo(), is(true)); command.undo(); verify(container).removeCard(card); }
@Override protected void createCommand() { command = new CreateCardCommand(); card = mock(Card.class); command.setModel(card); container = mock(CardContainer.class); command.setContainer(container); command.initialize(); }
@Test public void initialize() throws Exception { CreateCardCommand command = new CreateCardCommand(); command.initialize(); assertThat(command.canExecute(), is(false)); Card card = mock(Card.class); CardContainer container = mock(CardContainer.class); command.setModel(card); command.setContainer(container); command.initialize(); assertThat(command.canExecute(), is(true)); }
@Override public void execute() throws Exception { command.execute(); verify(container).addCard(card); }