<commit_before>
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.taskmanager.ui.CommandBox;

public class CommandBoxTest extends TaskManagerGuiTest {

    private static final String COMMAND_THAT_SUCCEEDS = "mark 3 done";
    private static final String ANOTHER_COMMAND_THAT_SUCCEEDS = "add valid name s/today e/next week";
    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());
    }

    // @@author A0130277L
    @Test
    public void commandBox_previousCommand() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        assertEquals(ANOTHER_COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_nextCommand() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.nextCommand();
        assertEquals(ANOTHER_COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_previousCommand_exceedingIndex() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_nextCommand_exceedingIndex() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.nextCommand();
        commandBox.nextCommand();
        commandBox.nextCommand();
        assertEquals(ANOTHER_COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }
    // @@author

}<commit_msg>fixed commandbox test error<commit_after>
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.taskmanager.ui.CommandBox;

public class CommandBoxTest extends TaskManagerGuiTest {

    private static final String COMMAND_THAT_SUCCEEDS = "mark 3 done";
    private static final String ANOTHER_COMMAND_THAT_SUCCEEDS = "add valid name s/today e/next week";
    private static final String COMMAND_THAT_FAILS = "invalid command";

    private static final String FIRST_INDEXT_COMMAND_STRING = "";


    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());
    }

    // @@author A0130277L
    @Test
    public void commandBox_previousCommand() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        assertEquals(ANOTHER_COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_nextCommand() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.nextCommand();
        assertEquals(ANOTHER_COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_previousCommand_exceedingIndex() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
        commandBox.previousCommand();
        assertEquals(COMMAND_THAT_SUCCEEDS, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_nextCommand_exceedingIndex() {
        commandBox.runCommand(COMMAND_THAT_SUCCEEDS);
        commandBox.runCommand(ANOTHER_COMMAND_THAT_SUCCEEDS);
        commandBox.previousCommand();
        commandBox.previousCommand();
        commandBox.nextCommand();
        commandBox.nextCommand();
        commandBox.nextCommand();
        assertEquals(FIRST_INDEXT_COMMAND_STRING, commandBox.getCommandInput());
    }
    // @@author

}
{'fraction_non_alphanumeric': 0.0823293172690763, 'fraction_numerical': 0.002008032128514056, 'mean_word_length': 4.053265694356373, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4638679', 'n_tokens_mistral': 2294, 'n_tokens_neox': 2202, 'n_words': 348}