void () { Module module = new MockModule(getTestRootDisposable()); final MyElement element = getDomManager().createMockElement(MyElement.class, module, false); assertSame(module, element.getModule()); assertTrue(element.isValid()); assertNull(element.getXmlTag()); assertEquals(element, DomUtil.getFileElement(element).getRootElement()); assertFalse(DomUtil.getFile(element).isPhysical()); final MyElement element2 = getDomManager().createMockElement(MyElement.class, null, false); assertNull(element2.getModule()); assertNull(element2.getXmlTag()); element2.addChildElement().getGenericValue().setStringValue("xxx"); assertNotNull(element2.getXmlTag()); final MyElement oldChild = element2.getChild(); element.getAttr().setValue("attr"); element.getGenericValue().setValue(Boolean.TRUE); element.getChild().getGenericValue().setStringValue("abc"); element.addChildElement().getGenericValue().setStringValue("def"); WriteCommandAction.runWriteCommandAction(getProject(), () -> element2.copyFrom(element)); assertEquals("attr", element2.getAttr().getValue()); assertEquals("true", element2.getGenericValue().getStringValue()); final MyElement newChild = element2.getChild(); assertEquals("abc", newChild.getGenericValue().getStringValue()); final List<MyElement> childElements = element2.getChildElements(); assertEquals(1, childElements.size()); assertEquals("def", childElements.get(0).getGenericValue().getStringValue()); }