Skip to content
Snippets Groups Projects
Commit c6c46465 authored by George Adrian Stoica's avatar George Adrian Stoica
Browse files

changes waitForNode to use asserttion

closes  #24
parent d270623e
Branches
No related tags found
1 merge request!4changes waitForNode to use assertion
......@@ -6,6 +6,7 @@ import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import static java.time.Duration.ofSeconds;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
......@@ -14,13 +15,13 @@ import javafx.scene.control.ListView;
import javafx.stage.Stage;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;
import todolist.core.AbstractTodoList;
......@@ -157,8 +158,9 @@ public class TodoListControllerTest extends ApplicationTest {
private Node waitForNode(Predicate<Node> nodeTest, int num) {
WaitForAsyncUtils.waitForFxEvents();
Node[] nodes = new Node[1];
try {
WaitForAsyncUtils.waitFor(2000, TimeUnit.MILLISECONDS,
boolean nodeFound;
nodeFound = assertTimeoutPreemptively(ofSeconds(2),
() -> {
while (true) {
if ((nodes[0] = findNode(nodeTest, num)) != null) {
......@@ -166,11 +168,9 @@ public class TodoListControllerTest extends ApplicationTest {
}
Thread.sleep(100);
}
}
},
"No appropriate node available"
);
} catch (TimeoutException e) {
fail("No appropriate node available");
}
return nodes[0];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment