@Test
  void closeModuleDestroyInactiveDialogClose() {
    // open two modules, close first (inactive) module
    // destroy() on first module will return false, so the module shouldn't get closed
    when(first.destroy()).then(invocation -> {
      // dialog opens
      return false;
    });
    robot.interact(() -> {
      workbench.openModule(first);
      workbench.openModule(second);
      workbench.closeModule(first);
      // user confirms yes on dialog: WorkbenchModule#close()
      simulateModuleClose(first);

      assertSame(second, workbench.getActiveModule());
      assertSame(moduleNodes[SECOND_INDEX], workbench.getActiveModuleView());
      assertEquals(1, workbench.getOpenModules().size());

      InOrder inOrder = inOrder(first, second);
      // Call: workbench.openModule(first)
      inOrder.verify(first).init(workbench);
      inOrder.verify(first).activate();
      // Call: workbench.openModule(second)
      inOrder.verify(first).deactivate();
      inOrder.verify(second).init(workbench);
      inOrder.verify(second).activate();
      // Call: workbench.closeModule(first)
      // attempt to destroy first
      inOrder.verify(first).destroy();
      // destroy() returns false, closeModule() opens first module
      inOrder.verify(second).deactivate();
      inOrder.verify(first).activate();
      // WorkbenchModule#close(), switch to second
      inOrder.verify(first).deactivate();
      inOrder.verify(second).activate();

      ignoreModuleGetters(first, second);
      verifyNoMoreInteractions(first, second);
    });
  }
Example of what happens in case of a closing dialog in the destroy() method of a module with
the user confirming the module should get closed. Precondition: openModule tests pass.
workbenchfx-core/src/test/java/com/dlsc/workbenchfx/WorkbenchTest.java