package guitests;

import static org.junit.Assert.assertEquals;

import java.util.Set;

import org.junit.Test;

import javafx.scene.Node;
import javafx.scene.control.TitledPane;

public class ViewCommandTest extends TaskManagerGuiTest {

    protected final String TASK_LIST_FXML_ID = "#taskListView";

    @Test
    public void viewDefault() {
        assertGroupsDisplay("All");
    }

    @Test
    public void viewCalendar() {
        commandBox.runCommand("view calendar");
        assertGroupsDisplay("Floating", "Overdue", "Today", "Tomorrow", "Future");
    }

    @Test
    public void viewGroups() {
        commandBox.runCommand("view done today tomorrow");
        assertGroupsDisplay("Done", "Today", "Tomorrow");
    }

    protected void assertGroupsDisplay(String... groupTitles) {
        Node taskListView = mainGui.getNodeWithID(TASK_LIST_FXML_ID);
        Set<Node> taskGroupNodes = taskListView.lookupAll("#titledPane");

        int index = 0;
        for (Node node : taskGroupNodes) {
            TitledPane titledPane = (TitledPane) node;
            // Title consists of title + no. of entries
            // e.g. Tomorrow (4)
            String title = titledPane.getText().split(" ")[0];
            assertEquals(title, groupTitles[index]);
            index++;
        }
    }

}

@@ -172,16 +172,66 @@
 dPane;%0A%0A
+import seedu.address.logic.commands.ViewCommand;%0A%0A
 public c
@@ -601,24 +601,109 @@
  %22Future%22);%0A
+        assertResultMessage(String.format(ViewCommand.MESSAGE_SUCCESS, %22Calendar%22));%0A
     %7D%0A%0A    @
@@ -793,24 +793,24 @@
 tomorrow%22);%0A
-
         asse
@@ -851,24 +851,316 @@
 Tomorrow%22);%0A
+        assertResultMessage(String.format(ViewCommand.MESSAGE_SUCCESS, %22Done%7CToday%7CTomorrow%22));%0A    %7D%0A%0A    @Test%0A    public void viewWrongInput() %7B%0A        commandBox.runCommand(%22view randomstring%22);%0A        assertGroupsDisplay(%22All%22);%0A        assertResultMessage(ViewCommand.MESSAGE_ERROR);%0A
     %7D%0A%0A    p

Add tests for View Command