From c32c15afaa2a561181bab8d0336123748f701a1d Mon Sep 17 00:00:00 2001 From: "DESKTOP-E8PT9RL\\Yichen" Date: Mon, 24 Oct 2016 12:25:58 +0900 Subject: [PATCH] Change view command output a bit. Add guitest for edit command more guitests on agenda coming --- .../java/seedu/address/logic/commands/ViewCommand.java | 6 +++++- src/test/java/guitests/EditCommandTest.java | 7 +++++++ src/test/java/seedu/address/logic/LogicManagerTest.java | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ViewCommand.java b/src/main/java/seedu/address/logic/commands/ViewCommand.java index 9dc6ba428a32..5a5d79d5758b 100644 --- a/src/main/java/seedu/address/logic/commands/ViewCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewCommand.java @@ -1,5 +1,7 @@ package seedu.address.logic.commands; +import java.text.SimpleDateFormat; + import seedu.address.commons.core.EventsCenter; import seedu.address.commons.events.ui.AgendaTimeRangeChangedEvent; import seedu.address.model.task.TaskDate; @@ -11,6 +13,8 @@ public class ViewCommand extends Command { public final TaskDate inputDate; + + private SimpleDateFormat formatter = new SimpleDateFormat("yyyy MMM dd, EEE"); public static final String COMMAND_WORD = "view"; @@ -29,7 +33,7 @@ public ViewCommand(TaskDate inputDate) { public CommandResult execute() { EventsCenter.getInstance().post(new AgendaTimeRangeChangedEvent(inputDate, model.getTaskMaster().getTaskComponentList())); - return new CommandResult(String.format(MESSAGE_UPDATE_AGENDA_SUCCESS, inputDate.getFormattedDate())); + return new CommandResult(String.format(MESSAGE_UPDATE_AGENDA_SUCCESS, formatter.format(inputDate.getDate()))); } diff --git a/src/test/java/guitests/EditCommandTest.java b/src/test/java/guitests/EditCommandTest.java index 6b8c45505adf..16e9d6cf2e9a 100644 --- a/src/test/java/guitests/EditCommandTest.java +++ b/src/test/java/guitests/EditCommandTest.java @@ -6,6 +6,7 @@ import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; import seedu.address.model.task.Name; +import seedu.address.model.task.RecurringType; import seedu.address.model.task.TaskDate; import seedu.address.model.task.TaskComponent; import seedu.address.commons.core.Messages; @@ -62,6 +63,12 @@ public void edit() throws IllegalValueException { //invalid command commandBox.runCommand("edits read weblecture"); assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND); + + //Edit a normal task to a recurring task, note the need to include a time point + toBeEdited = currentList[index - 1]; + toBeEdited.setRecurringType(RecurringType.MONTHLY); + currentList[index - 1] = toBeEdited; + assertEditSuccess(toBeEdited, "edit 4 from 2 oct 9am to 2 oct 11am monthly", currentList); } diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 49412a1ba345..56a569d8f31e 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -7,6 +7,7 @@ import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND; import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -76,6 +77,7 @@ public class LogicManagerTest { private Model model; private Logic logic; + private SimpleDateFormat formatter = new SimpleDateFormat("yyyy MMM dd, EEE"); //These are for checking the correctness of the events raised private ReadOnlyTaskMaster latestSavedTaskList; @@ -980,7 +982,7 @@ public void execute_view_successful() throws Exception { String test = "23 oct 12am"; TaskDate testDate = new TaskDate(test); assertCommandBehavior("view 23 oct 12am", - String.format(ViewCommand.MESSAGE_UPDATE_AGENDA_SUCCESS, testDate.getFormattedDate())); + String.format(ViewCommand.MESSAGE_UPDATE_AGENDA_SUCCESS, formatter.format(testDate.getDate()))); assertEquals(testDate, checkDate); assertEquals(latestSavedTaskList.getTaskComponentList(), checkList); assertEquals(model.getTaskMaster().getTaskComponentList(), checkList);