package guitests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import seedu.ezdo.ui.CommandBox;

public class CommandBoxTest extends EzDoGuiTest {

    private static final String COMMAND_THAT_SUCCEEDS = "select 3";
    private static final String COMMAND_THAT_FAILS = "invalid command";

    private ArrayList<String> defaultStyleOfCommandBox;
    private ArrayList<String> errorStyleOfCommandBox;

    @Before
    public void setUp() {
        defaultStyleOfCommandBox = new ArrayList<>(commandBox.getStyleClass());
        assertFalse("CommandBox default style classes should not contain error style class.",
                    defaultStyleOfCommandBox.contains(CommandBox.ERROR_STYLE_CLASS));

        // build style class for error
        errorStyleOfCommandBox = new ArrayList<>(defaultStyleOfCommandBox);
        errorStyleOfCommandBox.add(CommandBox.ERROR_STYLE_CLASS);
    }

    @Test
    public void commandBox_commandSucceeds_textClearedAndStyleClassRemainsTheSame() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);

        assertEquals("", commandBox.getCommandInput());
        assertEquals(defaultStyleOfCommandBox, commandBox.getStyleClass());
    }

    @Test
    public void commandBox_commandFails_textStaysAndErrorStyleClassAdded() {
        commandBox.runCommand(COMMAND_THAT_FAILS);

        assertEquals(COMMAND_THAT_FAILS, commandBox.getCommandInput());
        assertEquals(errorStyleOfCommandBox, commandBox.getStyleClass());
    }

    @Test
    public void commandBox_commandSucceedsAfterFailedCommand_textClearedAndErrorStyleClassRemoved() {
        // add error style to simulate a failed command
        commandBox.getStyleClass().add(CommandBox.ERROR_STYLE_CLASS);

        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);

        assertEquals("", commandBox.getCommandInput());
        assertEquals(defaultStyleOfCommandBox, commandBox.getStyleClass());
    }

}

@@ -462,16 +462,72 @@
 andBox;%0A
+    private ArrayList%3CString%3E successStyleOfCommandBox;%0A
     priv
@@ -871,16 +871,195 @@
 LASS));%0A
+        assertFalse(%22CommandBox default style classes should not contain success style class.%22,%0A                defaultStyleOfCommandBox.contains(CommandBox.SUCCESS_STYLE_CLASS));
 %0A       
@@ -1232,16 +1232,205 @@
 CLASS);%0A
+        // build style class for success%0A        successStyleOfCommandBox = new ArrayList%3C%3E(defaultStyleOfCommandBox);%0A        successStyleOfCommandBox.add(CommandBox.SUCCESS_STYLE_CLASS);%0A
     %7D%0A%0A 
@@ -1496,16 +1496,23 @@
 aredAndS
+uccessS
 tyleClas
@@ -1516,22 +1516,13 @@
 lass
-RemainsTheSame
+Added
 () %7B
@@ -1646,39 +1646,39 @@
    assertEquals(
-default
+success
 StyleOfCommandBo
@@ -2379,23 +2379,23 @@
 tEquals(
-default
+success
 StyleOfC

Update CommandBoxTest cases to include successStyleOfCommandBox