Skip to content

Commit

Permalink
Merge pull request #336 from Li-Shicheng/master
Browse files Browse the repository at this point in the history
Update EditCommandTest
  • Loading branch information
luishengjie authored Jul 24, 2017
2 parents 61a74b5 + 6fe3fc5 commit 59c6dca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ By : `T01-T4`      Since: `Jun 2017`    &nb
> **Reserved Tags**
>
> * Reserved tag `HIGH`, `MEDIUM`, `LOW` names are used to denote the importance of a certain task
> * Tagged task will be highlighted `RED`, `BLUE`, `GREEN`
> * Tagged task will be highlighted `RED`, `BLUE`, `GREEN` respectively for `HIGH`, `MEDIUM`, `LOW`
> * Reserved tag `OVERLAP` are used to warn you about overlapping events.
> **DateTime parsing**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/whatsnext/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Messages {
public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!";
public static final String MESSAGE_INVALID_LIST_COMMAND = "Invalid list command!";
public static final String MESSAGE_INVALID_FLOATING_TO_EVENT_TASK =
"Invalid Edit Command. Edit Command Parameters missing/invalid.";
"Invalid Edit Command. Edit Command Parameters missing/invalid.\n"
+ "Check your input and make sure the start date time is before the end date time. ";

}
32 changes: 32 additions & 0 deletions src/test/java/seedu/whatsnext/logic/commands/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static seedu.whatsnext.testutil.TypicalTasks.INDEX_SECOND_TASK;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
Expand Down Expand Up @@ -173,6 +174,30 @@ public void execute_editEventDateTimeUnfilteredList_success() throws Exception {
CommandTestUtil.assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
}

@Test
public void execute_editEventDateTimeFilteredList_success() throws Exception {
showFirstTaskOnly();

final String validOverlapStartDateTime = "22 Dec 10am";
final String validOverlapEndDateTime = "24 Dec 12pm";
BasicTask editedTask = new TaskBuilder().withName(VALID_NAME_PROJECTMEETING)
.withStartDateTime(validOverlapStartDateTime)
.withEndDateTime(validOverlapEndDateTime)
.withTags(VALID_TAG_HIGH, VALID_TAG_OVERLAP)
.withDescription(VALID_DESCRIPTION_PROJECTMEETING).build();
EditTaskDescriptor descriptor = new EditTaskDescriptorBuilder(editedTask).withNewTags(VALID_TAG_HIGH)
.withRemoveTags(VALID_TAG_CS2103).build();
EditCommand editCommand = prepareCommand(INDEX_FIRST_TASK, descriptor);

String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_TASK_SUCCESS, editedTask);

Model expectedModel = new ModelManager(new TaskManager(model.getTaskManager()), new UserPrefs());
expectedModel.updateTask(model.getFilteredTaskList().get(0), editedTask);
showNoTask(expectedModel);

CommandTestUtil.assertCommandSuccess(editCommand, model, expectedMessage, expectedModel);
}

//@@author A0156106M
@Test
public void execute_duplicateTaskUnfilteredList_failure() throws Exception {
Expand Down Expand Up @@ -276,4 +301,11 @@ private void showFirstTaskOnly(Model model) {

assertTrue(model.getFilteredTaskList().size() == 1);
}

private void showNoTask(Model model) {
model.updateFilteredTaskList(Collections.emptySet());

assert model.getFilteredTaskList().isEmpty();
}

}

0 comments on commit 59c6dca

Please sign in to comment.