void () { ApplicationManager.getApplication().invokeAndWait(() -> { ModalityState state = ModalityState.stateForComponent(myModalDialog); AtomicBoolean invoked = new AtomicBoolean(); ApplicationManager.getApplication().invokeLater(() -> invoked.set(true), state); LaterInvocator.enterModal("some object"); UIUtil.dispatchAllInvocationEvents(); assertFalse(invoked.get()); LaterInvocator.enterModal(myModalDialog); UIUtil.dispatchAllInvocationEvents(); assertTrue(invoked.get()); }); }