Search in sources :

Example 1 with PrimitiveXNodeImpl

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

the class TestDiffEquals method testRawValuesHashCode.

// MID-5851
@Test
public void testRawValuesHashCode() throws SchemaException {
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    QName extensionPropertyName = new QName(NS_TEST_RI, "extensionProperty");
    MutablePrismPropertyDefinition<String> extensionPropertyDef = prismContext.definitionFactory().createPropertyDefinition(extensionPropertyName, DOMUtil.XSD_STRING);
    extensionPropertyDef.setRuntimeSchema(true);
    PrismProperty<String> propertyParsed = extensionPropertyDef.instantiate();
    PrismProperty<String> propertyRaw = extensionPropertyDef.instantiate();
    propertyParsed.setRealValue("value");
    propertyRaw.setValue(prismContext.itemFactory().createPropertyValue(new PrimitiveXNodeImpl<>("value")));
    PrismObject<UserType> userParsed = new UserType(prismContext).name("user").asPrismObject();
    userParsed.getOrCreateExtension().add(propertyParsed);
    PrismObject<UserType> userRaw = new UserType(prismContext).name("user").asPrismObject();
    userRaw.getOrCreateExtension().add(propertyRaw);
    assertHashAndEquals(userParsed, userRaw, null);
    assertHashAndEquals(userParsed, userRaw, LITERAL);
    assertHashAndEquals(userParsed, userRaw, DATA);
}
Also used : QName(javax.xml.namespace.QName) PrimitiveXNodeImpl(com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl) Test(org.testng.annotations.Test)

Example 2 with PrimitiveXNodeImpl

use of com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl 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)

Aggregations

PrimitiveXNodeImpl (com.evolveum.midpoint.prism.impl.xnode.PrimitiveXNodeImpl)2 QName (javax.xml.namespace.QName)2 Test (org.testng.annotations.Test)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 ListXNode (com.evolveum.midpoint.prism.xnode.ListXNode)1 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)1 RootXNode (com.evolveum.midpoint.prism.xnode.RootXNode)1 XNode (com.evolveum.midpoint.prism.xnode.XNode)1 PipelineDataType (com.evolveum.midpoint.xml.ns._public.model.scripting_3.PipelineDataType)1