3333import org .apache .commons .lang3 .reflect .MethodUtils ;
3434import org .apache .maven .model .Model ;
3535import org .apache .maven .model .io .xpp3 .MavenXpp3Reader ;
36- import org .awaitility .Awaitility ;
37- import org .awaitility .core .ConditionTimeoutException ;
3836import org .hamcrest .Matchers ;
3937import org .testfx .robot .Motion ;
4038import javafx .scene .input .MouseButton ;
5856import java .util .List ;
5957import java .util .concurrent .TimeUnit ;
6058import java .util .concurrent .TimeoutException ;
61- import java .util .concurrent .atomic .AtomicReference ;
6259import java .util .jar .JarEntry ;
6360import java .util .jar .JarFile ;
6461import java .util .regex .Matcher ;
@@ -78,28 +75,21 @@ public static Node waitUntilExists(String target) {
7875 }
7976
8077 public static Node waitUntilExists (String target , int timeout , String timeUnit ) {
81- RobotLog .trace ("Waiting until target \" " + target + "\" becomes existent, timeout=" + timeout + ", timeUnit=" + timeUnit );
78+ RobotLog .trace ("Waiting until target \" " + target + "\" becomes existent, timeout="
79+ + Integer .toString (timeout ) + ", timeUnit=" + timeUnit );
8280
8381 try {
84- Awaitility .setDefaultTimeout (timeout , getTimeUnit (timeUnit ));
85- AtomicReference <Node > node = new AtomicReference <>();
86- Awaitility .await ().until (() -> {
87- try {
88- node .set (createFinder ().find (target ));
89- return node .get () != null ;
90- } catch (Exception e ) {
91- RobotLog .trace ("Exception in waitUntilExists: " + e + "\n " + e .getCause ());
92- return Boolean .FALSE ;
93- }
94- });
9582
96- RobotLog .trace ("Node located: \" " + node .get () + "\" " );
97- return node .get ();
83+ WaitForAsyncUtils .waitFor ((long ) timeout ,
84+ getTimeUnit (timeUnit ),
85+ () -> Matchers .is (isNotNull ()).matches (createFinder ().find (target )));
86+ return createFinder ().find (target );
9887
99- } catch (ConditionTimeoutException e ) {
88+ } catch (TimeoutException te ) {
10089 throw new JavaFXLibraryNonFatalException ("Given element \" " + target + "\" was not found within given timeout of "
10190 + Integer .toString (timeout ) + " " + timeUnit );
10291 } catch (Exception e ) {
92+ RobotLog .trace ("Exception in waitUntilExists: " + e + "\n " + e .getCause ().toString ());
10393 throw new JavaFXLibraryNonFatalException ("waitUntilExist failed: " + e );
10494 }
10595 }
0 commit comments