Search in sources :

Example 26 with RootXNode

use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.

the class TestParseTaskBulkAction2 method testParseTaskFileToXNode.

@Test
public void testParseTaskFileToXNode() throws Exception {
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    RootXNode node = prismContext.parserFor(TASK_FILE).xml().parseToXNode();
    // THEN
    System.out.println("Parsed task (XNode):");
    System.out.println(node.debugDump());
    System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node));
    System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) Test(org.testng.annotations.Test)

Example 27 with RootXNode

use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.

the class TestBasicPerformance method test340ParseXNode.

@Test
public void test340ParseXNode() throws Exception {
    PrismObject<UserType> jack = getJack();
    RootXNode xnode = getPrismContext().xnodeSerializer().serialize(jack);
    measure("parse.xnode.prism", "parse XNode", () -> getPrismContext().parserFor(xnode).parse());
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 28 with RootXNode

use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.

the class TestParseScriptOutput method testNamespaces.

@Test
public void testNamespaces() throws Exception {
    String file = MiscUtil.readFile(getFile());
    RootXNode xnode = getPrismContext().parserFor(file).parseToXNode();
    System.out.println("XNode:\n" + xnode.debugDump());
    String serialized = getPrismContext().xmlSerializer().serialize(xnode);
    System.out.println("XML: " + serialized);
    final String common_3 = "http://midpoint.evolveum.com/xml/ns/public/common/common-3";
    int count = StringUtils.countMatches(serialized, common_3);
    // temporarily set from 2 to 3 (some XML weirdness in Xerces 2.12/Xalan 2.7.2); see MID-5661
    assertEquals("Wrong # of occurrences of '" + common_3 + "' in serialized form", 2, count);
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) Test(org.testng.annotations.Test)

Example 29 with RootXNode

use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.

the class PrismTestUtil method displaySearchFilterType.

public static void displaySearchFilterType(SearchFilterType filterType) throws SchemaException {
    MapXNode mapXNode = filterType.getFilterClauseXNode();
    String dumpX = mapXNode.debugDump();
    LOGGER.info(dumpX);
    System.out.println(dumpX);
    String dumpXml = prismContext.xmlSerializer().serialize(new RootXNode(new QName("query"), mapXNode));
    System.out.println(dumpXml);
}
Also used : QName(javax.xml.namespace.QName) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode)

Example 30 with RootXNode

use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.

the class PrismParserImpl method doParseAnyValueAsJAXBElement.

@SuppressWarnings("unchecked")
<T> JAXBElement<T> doParseAnyValueAsJAXBElement() throws IOException, SchemaException {
    RootXNode root = getLexicalProcessor().read(source, context);
    T real = doParseRealValue(null, root);
    return real != null ? new JAXBElement<>(root.getRootElementName(), (Class<T>) real.getClass(), real) : null;
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode)

Aggregations

RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)51 Test (org.testng.annotations.Test)22 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)14 QName (javax.xml.namespace.QName)13 XNode (com.evolveum.midpoint.prism.xnode.XNode)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)7 NotNull (org.jetbrains.annotations.NotNull)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ListXNode (com.evolveum.midpoint.prism.xnode.ListXNode)6 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)4 SchemaXNode (com.evolveum.midpoint.prism.xnode.SchemaXNode)3 ArrayList (java.util.ArrayList)3 ResourceType (com.evolveum.midpoint.prism.foo.ResourceType)2 UserType (com.evolveum.midpoint.prism.foo.UserType)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 Element (org.w3c.dom.Element)2