void () { Disposable parent = Disposer.newDisposable("parent"); Disposable child = Disposer.newDisposable("child"); Disposer.register(parent, child); Disposable grand = Disposer.newDisposable("grand"); Disposer.register(child, grand); try { UsefulTestCase.assertThrows(IncorrectOperationException.class, "'grand' was already added as a child of 'parent'", () -> Disposer.register(grand, parent)); } finally { Disposer.dispose(grand); Disposer.dispose(child); Disposer.dispose(parent); } }