void () { final MyElement element = createElement("<a><child-element/><child-element/><child-element/></a>"); final MyElement child1 = element.getChildElements().get(0); final MyElement child2 = element.getChildElements().get(1); final MyElement child3 = element.getChildElements().get(2); final List<XmlTag> oldChildren = new ArrayList<>(Arrays.asList(element.getXmlTag().getSubTags())); assertTrue(child2.isValid()); assertEquals(element, child2.getParent()); WriteCommandAction.runWriteCommandAction(null, () -> { child2.undefine(); assertFalse(child2.isValid()); oldChildren.remove(1); assertEquals(oldChildren, Arrays.asList(element.getXmlTag().getSubTags())); assertEquals(Arrays.asList(child1, child3), element.getChildElements()); assertCached(child1, element.getXmlTag().findSubTags("child-element")[0]); assertCached(child3, element.getXmlTag().findSubTags("child-element")[1]); }); myCallRegistry.putExpected(new DomEvent(element, false)); myCallRegistry.assertResultsAndClear(); }