This repository has been archived by the owner on Mar 2, 2019. It is now read-only.
forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
781 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!--@@author generated--> | ||
|
||
<?import javafx.scene.layout.FlowPane?> | ||
|
||
<FlowPane alignment="CENTER_LEFT" maxWidth="-Infinity" minWidth="-Infinity" styleClass="viewFilter" | ||
xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" | ||
fx:controller="seedu.todo.ui.view.FilterBarView"> | ||
|
||
<FlowPane fx:id="filterBarView" alignment="CENTER_LEFT" maxWidth="-Infinity" minWidth="-Infinity" styleClass="viewFilter" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.FilterBarView"> | ||
</FlowPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package guitests; | ||
|
||
import org.junit.Test; | ||
import seedu.todo.logic.commands.CommandMap; | ||
import seedu.todo.logic.commands.CommandSummary; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
//@@author A0135805H | ||
/** | ||
* Tests the display of help command. | ||
*/ | ||
public class HelpCommandTest extends TodoListGuiTest { | ||
|
||
@Test | ||
public void help_showHelpPanelWithFull() { | ||
//Should display help with the complete "help" word. | ||
runCommand("help"); | ||
assertHelpViewDisplayed(); | ||
} | ||
|
||
@Test | ||
public void help_showHelpPanelWithShort() { | ||
//Should display help with an incomplete word of "help". | ||
runCommand("h"); | ||
assertHelpViewDisplayed(); | ||
} | ||
|
||
/** | ||
* Helper method to check if the help view is shown, and the content is correctly displayed. | ||
*/ | ||
private void assertHelpViewDisplayed() { | ||
assertTrue(helpView.isVisible()); | ||
assertTrue(helpView.isHelpItemsDisplayedCorrectly(getAllCommandSummaryArray())); | ||
} | ||
|
||
/* Helper Methods */ | ||
/** | ||
* Get a representation of the command summary by a list of array strings, where each item has the | ||
* following format: | ||
* [Scenario, Command, Arguments] | ||
*/ | ||
private List<String[]> getAllCommandSummaryArray() { | ||
return CommandMap.getAllCommandSummary().stream() | ||
.map(CommandSummary::toArray) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package guitests; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.junit.Test; | ||
import seedu.todo.model.TodoList; | ||
import seedu.todo.model.tag.Tag; | ||
import seedu.todo.model.task.ImmutableTask; | ||
import seedu.todo.testutil.TaskBuilder; | ||
import seedu.todo.testutil.TaskFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
//@@author A0135805H | ||
/** | ||
* Tests the tag command, including: | ||
* 1. Display the global list of tags. | ||
* 2. TODO: CRUD of tags. | ||
*/ | ||
public class TagCommandTest extends TodoListGuiTest { | ||
|
||
@Override | ||
protected TodoList getInitialData() { | ||
List<ImmutableTask> tasks = new ArrayList<>(); | ||
|
||
//Initialise some dummy tasks with tags. | ||
for (int numOfTags = 0; numOfTags <= 5; numOfTags ++) { | ||
String[] listOfTagNames = TaskFactory.randomTags(numOfTags); | ||
|
||
ImmutableTask task = TaskBuilder.name(TaskFactory.taskTitle()) | ||
.tagged(listOfTagNames).build(); | ||
|
||
tasks.add(task); | ||
} | ||
|
||
return getInitialDataHelper(tasks); | ||
} | ||
|
||
/* Actual Tests */ | ||
@Test | ||
public void tags_displayGlobalTagList() { | ||
//Check that all the tags are displayed, and they are unique. | ||
runCommand("tag"); | ||
List<String> displayedTagNames = globalTagView.getDisplayedTags(); | ||
assertNoDuplicate(displayedTagNames); | ||
assertEqualTagNames(getTagList(todoListView.getImmutableTaskList()), | ||
Sets.newHashSet(displayedTagNames)); | ||
} | ||
|
||
/* Helper Method */ | ||
/** | ||
* Get the list of tags given a listof {@code tasks} | ||
*/ | ||
private Set<String> getTagList(List<ImmutableTask> tasks) { | ||
Set<String> listOfTagNames = new HashSet<>(); | ||
tasks.forEach(task -> listOfTagNames.addAll(Tag.getLowerCaseNames(task.getTags()))); | ||
return listOfTagNames; | ||
} | ||
|
||
/** | ||
* Asserts that two sets are equal (with no case sensitivity) | ||
*/ | ||
private void assertEqualTagNames(Set<String> tagNames1, Set<String> tagNames2) { | ||
tagNames1 = tagNames1.stream() | ||
.map(String::toLowerCase) | ||
.collect(Collectors.toSet()); | ||
tagNames2 = tagNames2.stream() | ||
.map(String::toLowerCase) | ||
.collect(Collectors.toSet()); | ||
assertEquals(tagNames1, tagNames2); | ||
} | ||
|
||
/** | ||
* Asserts that there are no duplicate strings | ||
*/ | ||
private void assertNoDuplicate(List<String> strings) { | ||
Set<String> stringSet = new HashSet<>(strings); | ||
assertTrue(strings.size() == stringSet.size()); | ||
} | ||
} |
Oops, something went wrong.