Search in sources :

Example 41 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class TestModelWebServiceNegative method createShadowReplaceChange.

// TODO: more negative tests
private ObjectDeltaType createShadowReplaceChange(String oid, String path, final String value, QName type) {
    ObjectDeltaType objectChange = new ObjectDeltaType();
    objectChange.setOid(oid);
    objectChange.setChangeType(ChangeTypeType.MODIFY);
    objectChange.setObjectType(ObjectTypes.SHADOW.getTypeQName());
    ItemDeltaType itemDeltaType = new ItemDeltaType();
    itemDeltaType.setModificationType(ModificationTypeType.REPLACE);
    ItemPathType itemPath = new ItemPathType(path);
    itemDeltaType.setPath(itemPath);
    PrimitiveXNode<String> xnode = new PrimitiveXNode<>();
    ValueParser<String> valueParser = new ValueParser<String>() {

        @Override
        public String parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
            return value;
        }

        @Override
        public boolean isEmpty() {
            return false;
        }

        @Override
        public String getStringValue() {
            return value;
        }

        @Override
        public Map<String, String> getPotentiallyRelevantNamespaces() {
            throw new UnsupportedOperationException();
        }
    };
    xnode.setValueParser(valueParser);
    if (type != null) {
        xnode.setExplicitTypeDeclaration(true);
        xnode.setTypeQName(type);
    }
    RawType rawValue = new RawType(xnode, prismContext);
    itemDeltaType.getValue().add(rawValue);
    objectChange.getItemDelta().add(itemDeltaType);
    return objectChange;
}
Also used : XNodeProcessorEvaluationMode(com.evolveum.midpoint.prism.marshaller.XNodeProcessorEvaluationMode) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) ValueParser(com.evolveum.midpoint.prism.xnode.ValueParser) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 42 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class TestFundamentals method testRawTypeClone.

@Test
public void testRawTypeClone() throws Exception {
    System.out.println("\n\n===[ testRawTypeClone ]===\n");
    // GIVEN
    QName typeQName = new QName("abcdef");
    MapXNode mapXNode = new MapXNode();
    mapXNode.setTypeQName(typeQName);
    RawType rawType = new RawType(mapXNode, PrismTestUtil.getPrismContext());
    // WHEN
    RawType rawTypeClone = rawType.clone();
    // THEN
    assertEquals("Wrong or missing type QName", typeQName, rawTypeClone.getXnode().getTypeQName());
}
Also used : QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) Test(org.testng.annotations.Test)

Example 43 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class AccountConstructionType method clone.

public AccountConstructionType clone() {
    AccountConstructionType clone = new AccountConstructionType();
    clone.howto = howto;
    if (when != null) {
        clone.when = (XMLGregorianCalendar) when.clone();
    }
    for (RawType value : getValue()) {
        clone.getValue().add(value.clone());
    }
    return clone;
}
Also used : RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Example 44 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class TestParseMapping method makePPV.

// a bit of hack: RawType gets parsed very soon, so we must test for it almost immediately after parsing
@Override
protected PrismPropertyValue<MappingType> makePPV(MappingType mapping, PrismPropertyDefinition definition) {
    RawType variableValue = (RawType) mapping.getExpression().getVariable().get(0).getValue();
    AssertJUnit.assertNull("Unexpected raw value in expression variable: " + variableValue.getXnode(), variableValue.getXnode());
    return super.makePPV(mapping, definition);
}
Also used : RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Example 45 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class DeltaConvertor method addOldValues.

private static void addOldValues(ItemDelta delta, ItemDeltaType mod, Collection<PrismValue> values, DeltaConversionOptions options) throws SchemaException {
    if (values == null || values.isEmpty()) {
    //            RawType modValue = new RawType(delta.getPrismContext());
    //            mod.getEstimatedOldValue().add(modValue);
    } else {
        for (PrismValue value : values) {
            XNode xnode = toXNode(delta, value, options);
            RawType modValue = new RawType(xnode, delta.getPrismContext());
            mod.getEstimatedOldValue().add(modValue);
        }
    }
}
Also used : XNode(com.evolveum.midpoint.prism.xnode.XNode) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Aggregations

RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)62 QName (javax.xml.namespace.QName)22 Test (org.testng.annotations.Test)19 JAXBElement (javax.xml.bind.JAXBElement)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)10 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)9 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)9 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)9 ArrayList (java.util.ArrayList)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 Task (com.evolveum.midpoint.task.api.Task)8 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)7 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)6 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)6 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5