Skip to content

Commit

Permalink
Change view command output a bit.
Browse files Browse the repository at this point in the history
Add guitest for edit command
more guitests on agenda coming
  • Loading branch information
Yichen-D committed Oct 24, 2016
1 parent 4869a00 commit c32c15a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion 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;
Expand All @@ -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";

Expand All @@ -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())));

}

Expand Down
7 changes: 7 additions & 0 deletions src/test/java/guitests/EditCommandTest.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

}

Expand Down
4 changes: 3 additions & 1 deletion src/test/java/seedu/address/logic/LogicManagerTest.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c32c15a

Please sign in to comment.