package guitests;

import javafx.application.Platform;
import org.junit.Test;
import util.DialogMessage;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

import static org.junit.Assert.assertEquals;
import static org.loadui.testfx.Assertions.assertNodeExists;
import static org.loadui.testfx.controls.Commons.hasText;

public class DialogMessageTests extends UITest {

    @Test
    public void showErrorDialogTest() {
        Platform.runLater(() -> DialogMessage.showErrorDialog("Error", "Test Error Dialog"));
        waitUntilNodeAppears(hasText("Test Error Dialog"));
        assertNodeExists(hasText("Test Error Dialog"));
        clickOn("OK");
    }

    @Test
    public void showYesNoWarningDialogTest() throws ExecutionException, InterruptedException {
        FutureTask<Boolean> yesTask = new FutureTask<>(() ->
                DialogMessage.showYesNoWarningDialog("Warning", "Warning Header", "Warning Message", "yEs", "nO"));
        Platform.runLater(yesTask);
        waitUntilNodeAppears(hasText("Warning Header"));
        assertNodeExists(hasText("Warning Header"));
        clickOn("yEs");
        assertEquals(true, yesTask.get());
        FutureTask<Boolean> noTask = new FutureTask<>(() ->
                DialogMessage.showYesNoWarningDialog("Warning", "Warning Header", "Warning Message", "yEs", "nO"));
        Platform.runLater(noTask);
        waitUntilNodeAppears(hasText("Warning Message"));
        assertNodeExists(hasText("Warning Message"));
        clickOn("nO");
        assertEquals(false, noTask.get());
    }

    @Test
    public void showYesNoConfirmationDialog_tryYesAndNo_getCorrectValue() throws ExecutionException, InterruptedException {
        FutureTask<Boolean> yesTask = new FutureTask<>(() ->
                DialogMessage.showYesNoConfirmationDialog("Confirm", "Confirm Header", "Confirm Message", "yEs", "nO"));
        Platform.runLater(yesTask);
        waitUntilNodeAppears(hasText("Confirm Header"));
        assertNodeExists(hasText("Confirm Header"));
        clickOn("yEs");
        assertEquals(true, yesTask.get());

        FutureTask<Boolean> noTask = new FutureTask<>(() ->
                DialogMessage.showYesNoWarningDialog("Confirm", "Confirm Header", "Confirm Message", "yEs", "nO"));
        Platform.runLater(noTask);
        waitUntilNodeAppears(hasText("Confirm Message"));
        assertNodeExists(hasText("Confirm Message"));
        clickOn("nO");
        assertEquals(false, noTask.get());
    }

    @Test
    public void showInformationDialogTest() {
        Platform.runLater(() -> DialogMessage.showInformationDialog("Information", "Test Information Dialog"));
        waitUntilNodeAppears(hasText("Test Information Dialog"));
        assertNodeExists(hasText("Test Information Dialog"));
        clickOn("OK");
    }
}

@@ -1667,16 +1667,28 @@
 tValue()
+%0A           
  throws 
@@ -1722,32 +1722,33 @@
 ptedException %7B%0A
+%0A
         FutureTa
@@ -1896,32 +1896,32 @@
 Message%22, %22y
-E
+e
 s%22, %22n
-O
+o
 %22));%0A       
@@ -2069,33 +2069,33 @@
       clickOn(%22y
-E
+e
 s%22);%0A        ass
@@ -2283,35 +2283,114 @@
 rm Message%22,
- %22yEs%22, %22nO
+%0A                                                     %22Non-Standard-Yes%22, %22Non-Standard-No
 %22));%0A       
@@ -2538,34 +2538,47 @@
        clickOn(%22
-nO
+Non-Standard-No
 %22);%0A        asse

Make the DialogMessageTest clearer