void () { final XmlTag tag = XmlElementFactory.getInstance(getProject()).createTagFromText(" <foo/>"); WriteCommandAction.runWriteCommandAction(null, () -> { tag.add(XmlElementFactory.getInstance(getProject()).createDisplayText("aaa\nbbb")); }); assertEquals("aaa\nbbb", tag.getValue().getTextElements()[0].getValue()); }