package guitests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import javafx.scene.input.KeyCode;

public class RetrieveCommandHistoryTest extends GeeKeepGuiTest {

    private static final String COMMAND_ADD_LEARN_HASKELL = "add Learn Haskell";
    private static final String COMMAND_ADD_BUY_SPECTACLES = "add Buy spectacles";
    private static final String COMMAND_DELETE_1 = "delete 1";

    @Test
    public void commandBox_up_retrieve_previous_history() {
        commandBox.runCommand(COMMAND_ADD_LEARN_HASKELL);
        commandBox.runCommand(COMMAND_DELETE_1);
        commandBox.runCommand(COMMAND_ADD_BUY_SPECTACLES);
        commandBox.type(KeyCode.A, KeyCode.D, KeyCode.D);
        commandBox.pressEnter();
        commandBox.type(KeyCode.UP);
        assertEquals(COMMAND_ADD_BUY_SPECTACLES, commandBox.getCommandInput());
        commandBox.type(KeyCode.UP);
        assertEquals(COMMAND_ADD_LEARN_HASKELL, commandBox.getCommandInput());
        commandBox.type(KeyCode.UP);
        assertEquals(COMMAND_ADD_LEARN_HASKELL, commandBox.getCommandInput());
    }

    @Test
    public void commandBox_down_retrieve_next_history() {
        commandBox.runCommand(COMMAND_ADD_LEARN_HASKELL);
        commandBox.runCommand(COMMAND_DELETE_1);
        commandBox.runCommand(COMMAND_ADD_BUY_SPECTACLES);
        commandBox.type(KeyCode.A, KeyCode.D, KeyCode.D);
        commandBox.pressEnter();
        commandBox.type(KeyCode.UP);
        commandBox.type(KeyCode.UP);
        commandBox.type(KeyCode.DOWN);
        assertEquals(COMMAND_ADD_BUY_SPECTACLES, commandBox.getCommandInput());
        commandBox.type(KeyCode.DOWN);
        assertEquals("add", commandBox.getCommandInput());
        commandBox.type(KeyCode.DOWN);
        assertEquals("add", commandBox.getCommandInput());
    }

}

@@ -410,16 +410,64 @@
 lete 1%22;
+%0A    private static final String PREFIX = %22add%22;
 %0A%0A    @T
@@ -490,30 +490,16 @@
 oid 
-commandBox_up_
 retrieve
 _pre
@@ -498,19 +498,17 @@
 ieve
-_p
+P
 revious
-_h
+H
 isto
@@ -703,77 +703,27 @@
 Box.
-type(KeyCode.A, KeyCode.D, KeyCode.D);%0A        commandBox.pressEnter(
+enterCommand(PREFIX
 );%0A 
@@ -1107,32 +1107,16 @@
 oid 
-commandBox_down_
 retrieve
 _nex
@@ -1115,15 +1115,13 @@
 ieve
-_next_h
+NextH
 isto
@@ -1316,77 +1316,27 @@
 Box.
-type(KeyCode.A, KeyCode.D, KeyCode.D);%0A        commandBox.pressEnter(
+enterCommand(PREFIX
 );%0A 
@@ -1579,37 +1579,38 @@
    assertEquals(
-%22add%22
+PREFIX
 , commandBox.get
@@ -1686,21 +1686,22 @@
 tEquals(
-%22add%22
+PREFIX
 , comman

Change RetrieveCommandHistoryTest to enter command directly