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> successStyleOfCommandBox;
    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));
        assertFalse("CommandBox default style classes should not contain success style class.",
                defaultStyleOfCommandBox.contains(CommandBox.SUCCESS_STYLE_CLASS));
        // build style class for error
        errorStyleOfCommandBox = new ArrayList<>(defaultStyleOfCommandBox);
        errorStyleOfCommandBox.add(CommandBox.ERROR_STYLE_CLASS);
        // build style class for success
        successStyleOfCommandBox = new ArrayList<>(defaultStyleOfCommandBox);
        successStyleOfCommandBox.add(CommandBox.SUCCESS_STYLE_CLASS);
    }

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

        assertEquals("", commandBox.getCommandInput());
        assertEquals(successStyleOfCommandBox, 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(successStyleOfCommandBox, commandBox.getStyleClass());
    }

}

@@ -213,16 +213,36 @@
 andBox;%0A
+//@@author A0139177W
 %0Apublic 
@@ -430,64 +430,8 @@
 %22;%0A%0A
-    private ArrayList%3CString%3E defaultStyleOfCommandBox;%0A
     
@@ -578,24 +578,42 @@
 () %7B%0A       
+ ArrayList%3CString%3E
  defaultStyl

Replace defaultStyleOfCommandBox by a local variable