use of com.evolveum.midpoint.prism.foo.ResourceType in project midpoint by Evolveum.
the class AbstractLexicalProcessorTest method testParseResourceRumToPrism.
@Test
public void testParseResourceRumToPrism() throws Exception {
final String TEST_NAME = "testParseResourceRumToPrism";
displayTestTitle(TEST_NAME);
// GIVEN
LexicalProcessor lexicalProcessor = createParser();
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN (parse to xnode)
RootXNode xnode = lexicalProcessor.read(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());
// WHEN (parse to prism)
PrismObject<ResourceType> resource = prismContext.parserFor(xnode).parse();
// THEN
System.out.println("Parsed resource:");
System.out.println(resource.debugDump());
assertResourceRum(resource);
}
use of com.evolveum.midpoint.prism.foo.ResourceType in project midpoint by Evolveum.
the class AbstractLexicalProcessorTest method testParseResourceRoundTrip.
@Test
public void testParseResourceRoundTrip() throws Exception {
final String TEST_NAME = "testParseResourceRoundTrip";
displayTestTitle(TEST_NAME);
// GIVEN
LexicalProcessor<String> lexicalProcessor = createParser();
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN (parse)
RootXNode xnode = lexicalProcessor.read(getFileSource(RESOURCE_RUM_FILE_BASENAME), ParsingContext.createDefault());
PrismObject<ResourceType> resource = prismContext.parserFor(xnode).parse();
// THEN
System.out.println("\nParsed resource:");
System.out.println(resource.debugDump());
assertResourceRum(resource);
// WHEN (re-serialize to XNode)
XNode serializedXNode = prismContext.xnodeSerializer().options(SerializationOptions.createSerializeCompositeObjects()).serialize(resource);
String serializedString = lexicalProcessor.write(serializedXNode, new QName(NS_FOO, "resource"), null);
// THEN
System.out.println("\nXNode after re-serialization:");
System.out.println(serializedXNode.debugDump());
System.out.println("\nRe-serialized string:");
System.out.println(serializedString);
validateResourceSchema(serializedString, prismContext);
// WHEN (re-parse)
RootXNode reparsedXnode = lexicalProcessor.read(new ParserStringSource(serializedString), ParsingContext.createDefault());
PrismObject<ResourceType> reparsedResource = prismContext.parserFor(reparsedXnode).parse();
// THEN
System.out.println("\nXNode after re-parsing:");
System.out.println(reparsedXnode.debugDump());
System.out.println("\nRe-parsed resource:");
System.out.println(reparsedResource.debugDump());
ObjectDelta<ResourceType> diff = DiffUtil.diff(resource, reparsedResource);
System.out.println("\nDiff:");
System.out.println(diff.debugDump());
assertTrue("Re-parsed user does not match: " + diff, diff.isEmpty());
}
Aggregations