void (@NotNull TreePath path) { runOnSwingThread(() -> { tree.getModel().addTreeModelListener(new TreeModelAdapter() { @Override protected void process(@NotNull TreeModelEvent event, @NotNull EventType type) { assertEquals("unexpected tree path", path, event.getTreePath()); //noinspection SSBasedInspection SwingUtilities.invokeLater(ModelTest.this::done); } }); runOnModelThread(() -> { TreeModelEvent event = new TreeModelEvent(model, path); TreeModelListener[] listeners = ((DefaultTreeModel)model).getTreeModelListeners(); for (TreeModelListener listener : listeners) listener.treeStructureChanged(event); }); }); }