Search in sources :

Example 41 with RootXNode

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

the class TestParseScriptOutput method testParseToXNode.

@Test
public void testParseToXNode() throws Exception {
    String file = MiscUtil.readFile(getFile());
    System.out.println("Original text:\n" + file);
    RootXNode xnode = getPrismContext().parserFor(file).parseToXNode();
    System.out.println("XNode:\n" + xnode.debugDump());
    System.out.println("source -> XNode -> JSON:\n" + getPrismContext().jsonSerializer().serialize(xnode));
    System.out.println("source -> XNode -> YAML:\n" + getPrismContext().yamlSerializer().serialize(xnode));
    System.out.println("source -> XNode -> XML:\n" + getPrismContext().xmlSerializer().serialize(xnode));
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) Test(org.testng.annotations.Test)

Example 42 with RootXNode

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

the class TestParseScriptingExpressionXsiType method testYamlSerialization.

@Test
public void testYamlSerialization() throws Exception {
    String file = MiscUtil.readFile(getFile());
    System.out.println("Original text:\n" + file);
    RootXNode xnode = getPrismContext().parserFor(file).parseToXNode();
    System.out.println("XNode:\n" + xnode.debugDump());
    String yaml = getPrismContext().yamlSerializer().serialize(xnode);
    System.out.println("source -> XNode -> YAML:\n" + yaml);
    PrismValue value = getPrismContext().parserFor(yaml).parseItemValue();
    assertPrismPropertyValueLocal((PrismPropertyValue<ExpressionPipelineType>) value);
}
Also used : ExpressionPipelineType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExpressionPipelineType) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) Test(org.testng.annotations.Test)

Example 43 with RootXNode

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

the class PerfTestPrismObjectSize method generateTestObject.

private static final RootXNode generateTestObject(int count, int conflicts, boolean withIds) throws SchemaException, IOException {
    @NotNull PrismObject<UserType> baseObject = getJack();
    @NotNull RootXNode rootNode = getPrismContext().xnodeSerializer().serialize(baseObject);
    MapXNodeImpl user = (MapXNodeImpl) rootNode.getSubnode();
    ListXNodeImpl assignments = new ListXNodeImpl();
    int unique = count - conflicts;
    List<String> uuids = generateUUIDs(unique);
    for (int i = 0; i < unique; i++) {
        assignments.add(createXNodeAssignment(uuids.get(i), withIds ? i : -1));
    }
    for (int i = 0; i < conflicts; i++) {
        int id = unique - 1 - i;
        assignments.add(createXNodeAssignment(uuids.get(id), withIds ? id : -1));
    }
    user.put(UserType.F_ASSIGNMENT, assignments);
    return rootNode;
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) MapXNodeImpl(com.evolveum.midpoint.prism.impl.xnode.MapXNodeImpl) NotNull(org.jetbrains.annotations.NotNull) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ListXNodeImpl(com.evolveum.midpoint.prism.impl.xnode.ListXNodeImpl)

Example 44 with RootXNode

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

the class PerfTestPrismObjectSize method fromXnodeToPrism.

@Test(dataProvider = "combinationsConflicts")
public void fromXnodeToPrism(ContainerTestParams config) throws Exception {
    RootXNode input = config.testObject();
    PrismParserNoIO parser = getPrismContext().parserFor(input);
    String monitorId = monitorName("parse.prism", config.monitorId());
    String note = "Measures unmarshalling of Prism Objects from XNodes. Test parameters: " + config;
    measure(monitorId, note, parser::parse);
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) PrismParserNoIO(com.evolveum.midpoint.prism.PrismParserNoIO) Test(org.testng.annotations.Test)

Example 45 with RootXNode

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

the class PerfTestPrismObjectSize method fromXnodeToFile.

@Test(dataProvider = "combinations")
public void fromXnodeToFile(ContainerTestParams config) throws Exception {
    RootXNode input = config.testObject();
    for (String format : FILE_FORMATS) {
        PrismSerializer<String> serializer = getPrismContext().serializerFor(format);
        String monitorId = monitorName("serialize.xnode", config.monitorId(), format);
        String note = "Measures serialization from xnode to data stream. Test parameters: " + config;
        measure(monitorId, note, () -> serializer.serialize(input));
    }
}
Also used : RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) Test(org.testng.annotations.Test)

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