use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.
the class AbstractLexicalProcessorTest method assertUserJackXNodeOrdering.
protected void assertUserJackXNodeOrdering(String message, XNode xnode) {
if (xnode instanceof RootXNode) {
xnode = ((RootXNode) xnode).getSubnode();
}
MapXNode xmap = getAssertXNode(message + ": top", xnode, MapXNode.class);
Set<Entry<QName, XNode>> reTopMapEntrySet = xmap.entrySet();
Iterator<Entry<QName, XNode>> reTopMapEntrySetIter = reTopMapEntrySet.iterator();
Entry<QName, XNode> reTopMapEntry0 = reTopMapEntrySetIter.next();
assertEquals(message + ": Wrong entry 0, the xnodes were shuffled", "oid", reTopMapEntry0.getKey().getLocalPart());
Entry<QName, XNode> reTopMapEntry1 = reTopMapEntrySetIter.next();
assertEquals(message + ": Wrong entry 1, the xnodes were shuffled", "version", reTopMapEntry1.getKey().getLocalPart());
Entry<QName, XNode> reTopMapEntry2 = reTopMapEntrySetIter.next();
assertEquals(message + ": Wrong entry 2, the xnodes were shuffled", UserType.F_NAME, reTopMapEntry2.getKey());
Entry<QName, XNode> reTopMapEntry3 = reTopMapEntrySetIter.next();
assertEquals(message + ": Wrong entry 3, the xnodes were shuffled", UserType.F_DESCRIPTION, reTopMapEntry3.getKey());
}
use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.
the class AbstractLexicalProcessorTest method testParseEventHandler.
// The following is not supported now (and probably won't be in the future).
// Enable it if that changes.
@Test(enabled = false)
public void testParseEventHandler() throws Exception {
final String TEST_NAME = "testParseEventHandler";
displayTestTitle(TEST_NAME);
// GIVEN
LexicalProcessor lexicalProcessor = createParser();
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN (parse to xnode)
RootXNode xnode = lexicalProcessor.read(getFileSource(EVENT_HANDLER_FILE_BASENAME), ParsingContext.createDefault());
System.out.println("XNode after parsing:");
System.out.println(xnode.debugDump());
// WHEN (parse to prism)
EventHandlerType eventHandlerType = prismContext.parserFor(xnode).parseRealValue(EventHandlerChainType.class);
// EventHandlerType eventHandlerType = prismContext.getBeanConverter().unmarshall((MapXNode) , EventHandlerChainType.class,
// ParsingContext.createDefault());
// THEN
System.out.println("Parsed object:");
System.out.println(eventHandlerType);
// WHEN2 (marshalling)
MapXNode marshalled = (MapXNode) (prismContext.xnodeSerializer().serializeRealValue(eventHandlerType).getSubnode());
System.out.println("XNode after unmarshalling and marshalling back:");
System.out.println(marshalled.debugDump());
}
use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.
the class TestDomParser method testParseUserToXNode.
@Test
public void testParseUserToXNode() throws Exception {
final String TEST_NAME = "testParseUserToXNode";
displayTestTitle(TEST_NAME);
// GIVEN
DomLexicalProcessor parser = createParser();
// WHEN
XNode xnode = parser.read(getFile(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
// THEN
System.out.println("Parsed XNode:");
System.out.println(xnode.debugDump());
RootXNode root = getAssertXNode("root node", xnode, RootXNode.class);
MapXNode rootMap = getAssertXNode("root subnode", root.getSubnode(), MapXNode.class);
PrimitiveXNode<String> xname = getAssertXMapSubnode("root map", rootMap, UserType.F_NAME, PrimitiveXNode.class);
// TODO: assert value
ListXNode xass = getAssertXMapSubnode("root map", rootMap, UserType.F_ASSIGNMENT, ListXNode.class);
assertEquals("assignment size", 2, xass.size());
// TODO: asserts
MapXNode xextension = getAssertXMapSubnode("root map", rootMap, UserType.F_EXTENSION, MapXNode.class);
}
use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.
the class TestProtectedString method testParseProtectedStringEncrypted.
@Test
public void testParseProtectedStringEncrypted() throws Exception {
final String TEST_NAME = "testParseProtectedStringEncrypted";
displayTestTitle(TEST_NAME);
// GIVEN
Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128);
ProtectedStringType protectedStringType = protector.encryptString("salalala");
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
MapXNode protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null);
System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump());
// THEN
ProtectedStringType unmarshalled = new ProtectedStringType();
XNodeProcessorUtil.parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, ParsingContext.createDefault());
System.out.println("Unmarshalled value: " + unmarshalled);
assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
use of com.evolveum.midpoint.prism.xnode.MapXNode in project midpoint by Evolveum.
the class TestProtectedString method testParseProtectedStringHashed.
@Test
public void testParseProtectedStringHashed() throws Exception {
final String TEST_NAME = "testParseProtectedStringHashed";
displayTestTitle(TEST_NAME);
// GIVEN
ProtectedStringType protectedStringType = new ProtectedStringType();
protectedStringType.setClearValue("blabla");
Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128);
protector.hash(protectedStringType);
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
MapXNode protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null);
System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump());
// THEN
ProtectedStringType unmarshalled = new ProtectedStringType();
XNodeProcessorUtil.parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, ParsingContext.createDefault());
System.out.println("Unmarshalled value: " + unmarshalled);
assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
Aggregations