Skip to content

Commit

Permalink
Merge pull request #157 from juxd/remove-undo-redo
Browse files Browse the repository at this point in the history
Remove undo & redo commands
  • Loading branch information
kohchihao committed Nov 6, 2018
2 parents a3cb960 + 13b80ba commit 9c70d68
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 319 deletions.
31 changes: 0 additions & 31 deletions src/main/java/seedu/address/logic/commands/RedoCommand.java

This file was deleted.

31 changes: 0 additions & 31 deletions src/main/java/seedu/address/logic/commands/UndoCommand.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/java/seedu/address/logic/parser/OrderBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import seedu.address.logic.commands.HomeCommand;
import seedu.address.logic.commands.LoginCommand;
import seedu.address.logic.commands.LogoutCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.SignUpCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.deliveryman.DeliverymanCommand;
import seedu.address.logic.commands.order.OrderCommand;
import seedu.address.logic.parser.deliveryman.DeliverymanCommandParser;
Expand Down Expand Up @@ -65,12 +63,6 @@ public Command parseCommand(String userInput) throws ParseException {
case HelpCommand.COMMAND_WORD:
return new HelpCommand();

case UndoCommand.COMMAND_WORD:
return new UndoCommand();

case RedoCommand.COMMAND_WORD:
return new RedoCommand();

case SignUpCommand.COMMAND_WORD:
return new SignUpCommandParser().parse(arguments);

Expand Down
53 changes: 0 additions & 53 deletions src/test/java/seedu/address/logic/commands/RedoCommandTest.java

This file was deleted.

49 changes: 0 additions & 49 deletions src/test/java/seedu/address/logic/commands/UndoCommandTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package seedu.address.logic.commands.order;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
Expand All @@ -17,8 +16,6 @@
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
Expand Down Expand Up @@ -99,14 +96,6 @@ public void executeUndoRedo_validIndexUnfilteredList_success() throws Exception

// delete -> first common deleted
deleteCommand.execute(model, commandHistory);

// undo -> reverts addressbook back to previous state and filtered common list to show all persons
expectedModel.undoOrderBook();
assertCommandSuccess(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_SUCCESS, expectedModel);

// redo -> same first common deleted again
expectedModel.redoOrderBook();
assertCommandSuccess(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
Expand All @@ -116,10 +105,6 @@ public void executeUndoRedo_invalidIndexUnfilteredList_failure() {

// execution failed -> address book state not added into model
assertCommandFailure(deleteCommand, model, commandHistory, Messages.MESSAGE_INVALID_ORDER_DISPLAYED_INDEX);

// single address book state in model -> undoCommand and redoCommand fail
assertCommandFailure(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_FAILURE);
assertCommandFailure(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_FAILURE);
}

/**
Expand All @@ -142,15 +127,6 @@ public void executeUndoRedo_validIndexFilteredList_sameOrderDeleted() throws Exc

// delete -> deletes second common in unfiltered common list / first common in filtered common list
deleteCommand.execute(model, commandHistory);

// undo -> reverts addressbook back to previous state and filtered common list to show all persons
expectedModel.undoOrderBook();
assertCommandSuccess(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_SUCCESS, expectedModel);

assertNotEquals(orderToDelete, model.getFilteredOrderList().get(INDEX_FIRST.getZeroBased()));
// redo -> deletes same second common in unfiltered common list
expectedModel.redoOrderBook();
assertCommandSuccess(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB;
Expand All @@ -24,8 +23,6 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.commands.order.EditCommand.EditOrderDescriptor;
import seedu.address.model.Model;
Expand Down Expand Up @@ -176,14 +173,6 @@ public void executeUndoRedo_validIndexUnfilteredList_success() throws Exception

// edit -> first order edited
editCommand.execute(model, commandHistory);

// undo -> reverts orderbook back to previous state and filtered order list to show all orders
expectedModel.undoOrderBook();
assertCommandSuccess(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_SUCCESS, expectedModel);

// redo -> same first order edited again
expectedModel.redoOrderBook();
assertCommandSuccess(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
Expand All @@ -194,10 +183,6 @@ public void executeUndoRedo_invalidIndexUnfilteredList_failure() {

// execution failed -> order book state not added into model
assertCommandFailure(editCommand, model, commandHistory, Messages.MESSAGE_INVALID_ORDER_DISPLAYED_INDEX);

// single order book state in model -> undoCommand and redoCommand fail
assertCommandFailure(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_FAILURE);
assertCommandFailure(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_FAILURE);
}

@Test
Expand All @@ -215,15 +200,6 @@ public void executeUndoRedo_validIndexFilteredList_sameOrderEdited() throws Exce

// edit -> edits second order in unfiltered order list / first order in filtered order list
editCommand.execute(model, commandHistory);

// undo -> reverts orderbook back to previous state and filtered order list to show all orders
expectedModel.undoOrderBook();
assertCommandSuccess(new UndoCommand(), model, commandHistory, UndoCommand.MESSAGE_SUCCESS, expectedModel);

assertNotEquals(model.getFilteredOrderList().get(INDEX_FIRST.getZeroBased()), orderToEdit);
// redo -> edits same second order in unfiltered order list
expectedModel.redoOrderBook();
assertCommandSuccess(new RedoCommand(), model, commandHistory, RedoCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/seedu/address/logic/parser/OrderBookParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.HistoryCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.deliveryman.DeliverymanCommand;
import seedu.address.logic.commands.order.OrderCommand;
import seedu.address.logic.parser.exceptions.ParseException;
Expand Down Expand Up @@ -66,18 +64,6 @@ public void parseCommand_deliveryman() throws Exception {
parser.parseCommand(DeliverymanCommand.COMMAND_WORD);
}

@Test
public void parseCommand_redoCommandWord_returnsRedoCommand() throws Exception {
assertTrue(parser.parseCommand(RedoCommand.COMMAND_WORD) instanceof RedoCommand);
assertTrue(parser.parseCommand("/redo 1") instanceof RedoCommand);
}

@Test
public void parseCommand_undoCommandWord_returnsUndoCommand() throws Exception {
assertTrue(parser.parseCommand(UndoCommand.COMMAND_WORD) instanceof UndoCommand);
assertTrue(parser.parseCommand("/undo 3") instanceof UndoCommand);
}

@Test
public void parseCommand_unrecognisedInput_throwsParseException() throws Exception {
thrown.expect(ParseException.class);
Expand Down
13 changes: 0 additions & 13 deletions src/test/java/systemtests/AddCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.LoginCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.order.AddCommand;
import seedu.address.logic.commands.order.OrderCommand;
import seedu.address.model.Model;
Expand Down Expand Up @@ -70,17 +68,6 @@ public void add() {
+ " " + ADDRESS_DESC_AMY + " " + DATE_DESC_AMY + " " + FOOD_DESC_BURGER + " ";
assertCommandSuccess(command, toAdd);

/* Case: undo adding Amy to the list -> Amy deleted */
command = UndoCommand.COMMAND_WORD;
String expectedResultMessage = UndoCommand.MESSAGE_SUCCESS;
assertCommandSuccess(command, model, expectedResultMessage);

/* Case: redo adding Amy to the list -> Amy added again */
command = RedoCommand.COMMAND_WORD;
model.addOrder(toAdd);
expectedResultMessage = RedoCommand.MESSAGE_SUCCESS;
assertCommandSuccess(command, model, expectedResultMessage);

/* Case: add an order with all fields same as another order in the order book except name -> added */
toAdd = new OrderBuilder(AMY).withName(VALID_NAME_BOB).build();
command = addCommand + NAME_DESC_BOB + PHONE_DESC_AMY + ADDRESS_DESC_AMY + DATE_DESC_AMY
Expand Down
21 changes: 0 additions & 21 deletions src/test/java/systemtests/ClearCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

import org.junit.Test;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.LoginCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.order.ClearCommand;
import seedu.address.logic.commands.order.OrderCommand;
import seedu.address.model.Model;
Expand All @@ -38,24 +35,6 @@ public void clear() {
assertCommandSuccess(" " + clearCommand + " ab12 ");
assertSelectedCardUnchanged();

/* Case: undo clearing address book -> original address book restored */
command = UndoCommand.COMMAND_WORD;
String expectedResultMessage = UndoCommand.MESSAGE_SUCCESS;
assertCommandSuccess(command, expectedResultMessage, defaultModel);
assertSelectedCardUnchanged();

/* Case: redo clearing address book -> cleared */
command = RedoCommand.COMMAND_WORD;
expectedResultMessage = RedoCommand.MESSAGE_SUCCESS;
assertCommandSuccess(command, expectedResultMessage, new ModelManager());
assertSelectedCardUnchanged();

/* Case: selects first card in common list and clears address book -> cleared and no card selected */
executeCommand(UndoCommand.COMMAND_WORD); // restores the original address book
selectOrder(Index.fromOneBased(1));
assertCommandSuccess(clearCommand);
assertSelectedCardDeselected();

/* Case: clear empty address book -> cleared */
assertCommandSuccess(clearCommand);
assertSelectedCardUnchanged();
Expand Down
Loading

0 comments on commit 9c70d68

Please sign in to comment.