@Test
  @DisplayName("Show blocking dialog and close by clicking on one of the dialog buttons")
  void showDialogBlockingCloseButton() {
    robot.interact(() -> {
      when(mockDialog.isBlocking()).thenReturn(true);

      assertDialogNotShown();

      WorkbenchDialog result = workbench.showDialog(mockDialog);

      assertDialogShown(result, true);
      verify(mockDialog, atLeastOnce()).isBlocking(); // call showOverlay(...) inside showDialog()
      verify(mockDialog, atLeastOnce()).getButtonTypes();
      verify(mockDialog, atLeastOnce()).getDialogControl();
      verify(mockDialog, never()).getOnResult();
      verify(mockOnResult, never()).accept(any());
      ObservableList<Button> buttons = dialogControl.getButtons();
      assertSame(buttonTypes.size(), buttons.size());

      // hiding by button press
      ButtonType toPress = buttonTypes.get(0);
      simulateDialogButtonClick(dialogControl, toPress);

      verify(mockDialog, atLeast(0)).blockingProperty(); // ignore calls
      verify(mockDialog).getOnResult();
      verify(mockDialog, atLeastOnce()).getDialogControl();
      verify(mockOnResult).accept(toPress);
      verifyNoMoreInteractions(mockDialog);
      verifyNoMoreInteractions(mockOnResult);
      assertDialogNotShown();
    });
  }
Internal utility method for testing.
Simulates closing the stage, which fires a close request to test logic
inside of {@link Stage#setOnCloseRequest(EventHandler)}.
Using {@link FxRobot#closeCurrentWindow()} would be better, but it only works on Windows
because of its implementation, so this approach was chosen as a workaround.
@see <a href="https://github.com/TestFX/TestFX/issues/447">
closeCurrentWindow() doesn't work headless</a>
workbenchfx-core/src/test/java/com/dlsc/workbenchfx/WorkbenchTest.java