void (final TreeAction action) { final int[] notifyCount = new int[1]; final boolean[] done = new boolean[1]; invokeLaterIfNeeded(() -> action.run(() -> { notifyCount[0]++; done[0] = true; })); new WaitFor(2000) { @Override protected boolean condition() { return done[0] && getMyBuilder().getUi().isReady(); } }; assertTrue(done[0]); assertEquals(1, notifyCount[0]); }