Search in sources :

Example 1 with JDOMResult

use of org.jdom.transform.JDOMResult in project intellij-plugins by JetBrains.

the class FlashUmlTest method assertModel.

private void assertModel(final String expectedPrefix, final DiagramProvider<Object> provider, final String actualOriginFqn, final DiagramDataModel<Object> model) throws Exception {
    String expectedDataFileName = getTestName(false) + (StringUtil.isEmpty(expectedPrefix) ? ".expected.xml" : ".expected." + expectedPrefix + ".xml");
    CharSequence expectedText = LoadTextUtil.loadText(getVirtualFile(BASE_PATH + expectedDataFileName));
    final Element expected = JdomKt.loadElement(expectedText);
    final String expectedOriginFqn = expected.getAttributeValue("origin");
    assertEquals(expectedDataFileName + ": Invalid origin element", expectedOriginFqn, actualOriginFqn);
    JDOMResult actual = new JDOMResult();
    UmlDataModelDumper.dump(actual, provider, model);
    actual.getDocument().getRootElement().setAttribute("origin", actualOriginFqn);
    String difference = JDOMCompare.diffElements(expected, actual.getDocument().getRootElement());
    if (difference != null) {
        // this will fail if structure is different
        assertEquals(expectedDataFileName + ": " + difference, JDOMUtil.writeElement(expected), JDOMUtil.writeElement(actual.getDocument().getRootElement()).trim());
    }
}
Also used : JDOMResult(org.jdom.transform.JDOMResult) Element(org.jdom.Element)

Aggregations

Element (org.jdom.Element)1 JDOMResult (org.jdom.transform.JDOMResult)1