Search in sources :

Example 1 with MapXNode

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());
}
Also used : Entry(java.util.Map.Entry) QName(javax.xml.namespace.QName) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode)

Example 2 with MapXNode

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());
}
Also used : EventHandlerType(com.evolveum.midpoint.prism.foo.EventHandlerType) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) Test(org.testng.annotations.Test)

Example 3 with MapXNode

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);
}
Also used : DomLexicalProcessor(com.evolveum.midpoint.prism.lex.dom.DomLexicalProcessor) ListXNode(com.evolveum.midpoint.prism.xnode.ListXNode) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) ListXNode(com.evolveum.midpoint.prism.xnode.ListXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) Test(org.testng.annotations.Test)

Example 4 with MapXNode

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) TestProtector(com.evolveum.midpoint.prism.crypto.TestProtector) Protector(com.evolveum.midpoint.prism.crypto.Protector) Test(org.testng.annotations.Test)

Example 5 with MapXNode

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);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) TestProtector(com.evolveum.midpoint.prism.crypto.TestProtector) Protector(com.evolveum.midpoint.prism.crypto.Protector) Test(org.testng.annotations.Test)

Aggregations

MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)42 QName (javax.xml.namespace.QName)24 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)21 XNode (com.evolveum.midpoint.prism.xnode.XNode)18 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)15 ListXNode (com.evolveum.midpoint.prism.xnode.ListXNode)13 Test (org.testng.annotations.Test)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)9 SchemaXNode (com.evolveum.midpoint.prism.xnode.SchemaXNode)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)7 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)7 Element (org.w3c.dom.Element)6 PrismContext (com.evolveum.midpoint.prism.PrismContext)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)4 Protector (com.evolveum.midpoint.prism.crypto.Protector)3 EncryptedDataType (com.evolveum.prism.xml.ns._public.types_3.EncryptedDataType)3 NotNull (org.jetbrains.annotations.NotNull)3 TestProtector (com.evolveum.midpoint.prism.crypto.TestProtector)2