Search in sources :

Example 11 with ListXNode

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

the class TestBeanSerialization method testPipelineItemXsdType.

@Test
public void testPipelineItemXsdType() throws SchemaException {
    PipelineDataType bean = new PipelineDataType();
    bean.beginItem().value("s1");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    RootXNode xnode = prismContext.xnodeSerializer().root(new QName("output")).serializeRealValue(bean);
    MapXNode output = (MapXNode) xnode.toMapXNode().get(new QName("output"));
    XNode item = ((ListXNode) output.get(PipelineDataType.F_ITEM)).get(0);
    assertTrue(item instanceof MapXNode);
    XNode value = ((MapXNode) item).get(PipelineItemType.F_VALUE);
    assertTrue(value instanceof PrimitiveXNodeImpl);
    assertTrue(value.isExplicitTypeDeclaration());
    assertEquals(value.getTypeQName(), DOMUtil.XSD_STRING);
// displayValue("output in XML", prismContext.xmlSerializer().root(new QName("output")).serializeRealValue(bean));
}
Also used : ListXNode(com.evolveum.midpoint.prism.xnode.ListXNode) PrismContext(com.evolveum.midpoint.prism.PrismContext) QName(javax.xml.namespace.QName) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) 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) PrimitiveXNodeImpl(com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl) PipelineDataType(com.evolveum.midpoint.xml.ns._public.model.scripting_3.PipelineDataType) Test(org.testng.annotations.Test)

Example 12 with ListXNode

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

the class TestQueryConverter method testAccountFilter.

@Test
public void testAccountFilter() throws Exception {
    SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_FILE);
    ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
    displayQuery(query);
    assertNotNull(query);
    ObjectFilter filter = query.getFilter();
    PrismAsserts.assertAndFilter(filter, 2);
    ObjectFilter first = getFilterCondition(filter, 0);
    PrismAsserts.assertEqualsFilter(first, ShadowType.F_TAG, PrimitiveType.XSD_STRING, ShadowType.F_TAG);
    PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "abc");
    ObjectFilter second = getFilterCondition(filter, 1);
    PrismAsserts.assertEqualsFilter(second, ShadowType.F_NAME, PolyStringType.COMPLEX_TYPE, ShadowType.F_NAME);
    PrismAsserts.assertEqualsFilterValue((EqualFilter) second, createPolyString("someName"));
    QueryType convertedQueryType = toQueryType(query);
    System.out.println("Re-converted query type");
    System.out.println(convertedQueryType.debugDump());
    SearchFilterType convertedFilterType = convertedQueryType.getFilter();
    MapXNode xFilter = convertedFilterType.serializeToXNode(getPrismContext());
    PrismAsserts.assertSize(xFilter, 1);
    PrismAsserts.assertSubnode(xFilter, AndFilter.ELEMENT_NAME, MapXNode.class);
    MapXNode xandmap = (MapXNode) xFilter.get(AndFilter.ELEMENT_NAME);
    PrismAsserts.assertSize(xandmap, 1);
    PrismAsserts.assertSubnode(xandmap, EqualFilter.ELEMENT_NAME, ListXNode.class);
    ListXNode xequalsList = (ListXNode) xandmap.get(EqualFilter.ELEMENT_NAME);
    PrismAsserts.assertSize(xequalsList, 2);
// Element filterClauseElement = convertedFilterType.getFilterClauseAsElement(getPrismContext());
// System.out.println("Serialized filter (JAXB->DOM)");
// System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
// 
// DomAsserts.assertElementQName(filterClauseElement, AndFilter.ELEMENT_NAME);
// DomAsserts.assertSubElements(filterClauseElement, 2);
// 
// Element firstSubelement = DOMUtil.getChildElement(filterClauseElement, 0);
// DomAsserts.assertElementQName(firstSubelement, EqualFilter.ELEMENT_NAME);
// Element firstValueElement = DOMUtil.getChildElement(firstSubelement, PrismConstants.Q_VALUE);
// DomAsserts.assertTextContent(firstValueElement, "abc");
// 
// Element secondSubelement = DOMUtil.getChildElement(filterClauseElement, 1);
// DomAsserts.assertElementQName(secondSubelement, EqualFilter.ELEMENT_NAME);
// Element secondValueElement = DOMUtil.getChildElement(secondSubelement, PrismConstants.Q_VALUE);
// DomAsserts.assertTextContent(secondValueElement, "someName");
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) ListXNode(com.evolveum.midpoint.prism.xnode.ListXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Aggregations

ListXNode (com.evolveum.midpoint.prism.xnode.ListXNode)12 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)10 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)8 XNode (com.evolveum.midpoint.prism.xnode.XNode)8 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)7 SchemaXNode (com.evolveum.midpoint.prism.xnode.SchemaXNode)5 QName (javax.xml.namespace.QName)5 Test (org.testng.annotations.Test)5 Element (org.w3c.dom.Element)4 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)3 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrimitiveXNodeImpl (com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl)1 DomLexicalProcessor (com.evolveum.midpoint.prism.lex.dom.DomLexicalProcessor)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)1 PipelineDataType (com.evolveum.midpoint.xml.ns._public.model.scripting_3.PipelineDataType)1 NotNull (org.jetbrains.annotations.NotNull)1