use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class TestParseTaskBulkAction method testParseTaskRoundtrip.
@Test
public void testParseTaskRoundtrip() throws Exception {
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
PrismObject<TaskType> task = prismContext.parseObject(TASK_FILE);
System.out.println("Parsed task:");
System.out.println(task.debugDump());
assertTask(task);
// SERIALIZE
String serializedTask = prismContext.xmlSerializer().serialize(task);
System.out.println("serialized task:");
System.out.println(serializedTask);
// RE-PARSE
RootXNode reparsedToXNode = prismContext.parserFor(serializedTask).xml().parseToXNode();
System.out.println("Re-parsed task (to XNode):");
System.out.println(reparsedToXNode.debugDump());
// real reparse
PrismObject<TaskType> reparsedTask = prismContext.parseObject(serializedTask);
System.out.println("Re-parsed task:");
System.out.println(reparsedTask.debugDump());
// Cannot assert here. It will cause parsing of some of the raw values and diff will fail
assertTask(reparsedTask);
ObjectDelta<TaskType> objectDelta = task.diff(reparsedTask);
System.out.println("Delta:");
System.out.println(objectDelta.debugDump());
assertTrue("Delta is not empty", objectDelta.isEmpty());
PrismAsserts.assertEquivalent("Task re-parsed equivalence", task, reparsedTask);
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class TestParseTaskBulkAction 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));
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class TestParseForm method testParseToXNode.
@Test
public void testParseToXNode() throws Exception {
PrismContext prismContext = PrismTestUtil.getPrismContext();
RootXNode node = prismContext.parserFor(getFile()).parseToXNode();
System.out.println("Parsed to XNode:");
System.out.println(node.debugDump());
System.out.println("XML -> XNode -> XML:\n" + prismContext.xmlSerializer().serialize(node));
System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node));
System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node));
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class TestParseResource method testParseResourceDom.
// todo eliminate dependency on prism-impl
@Test
public void testParseResourceDom() throws Exception {
if (!"xml".equals(language)) {
return;
}
// GIVEN
PrismContext prismContext = getPrismContext();
// WHEN
DomLexicalProcessor parserDom = ((PrismContextImpl) prismContext).getParserDom();
RootXNode xnode = parserDom.read(new ParserFileSource(getFile(TestConstants.RESOURCE_FILE_BASENAME)), createDefaultParsingContext());
PrismObject<ResourceType> resource = prismContext.parserFor(xnode).parse();
// THEN
System.out.println("Parsed resource:");
System.out.println(resource.debugDump());
assertResource(resource, true, true, false);
}
use of com.evolveum.midpoint.prism.xnode.RootXNode in project midpoint by Evolveum.
the class TestParseScriptingExpression method testParseToXNode.
@Test
public void testParseToXNode() throws Exception {
ItemDefinition<?> sequenceDef = getPrismContext().getSchemaRegistry().findItemDefinitionByElementName(SchemaConstants.S_SEQUENCE);
System.out.println("sequence.substitutionHead = " + sequenceDef.getSubstitutionHead());
System.out.println("sequence.heterogeneousListItem = " + sequenceDef.isHeterogeneousListItem());
ComplexTypeDefinition sequenceCtd = getPrismContext().getSchemaRegistry().findComplexTypeDefinitionByType(sequenceDef.getTypeName());
System.out.println("ExpressionSequenceType.list = " + sequenceCtd.isListMarker());
System.out.println("\n\n-----------------------------------\n");
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));
}
Aggregations