Search in sources :

Example 11 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionAddObjectFalse.

public void testScriptSystemVariablesConditionAddObjectFalse(String filename) throws Exception {
    // GIVEN
    final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalse";
    System.out.println("===[ " + TEST_NAME + "]===");
    PrismObject<UserType> user = evaluator.getUserOld();
    user.asObjectable().getEmployeeType().clear();
    user.asObjectable().getEmployeeType().add("SAILOR");
    ObjectDelta<UserType> delta = ObjectDelta.createAddDelta(user);
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    assertNull("Unexpected output triple: " + outputTriple, outputTriple);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 12 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class ModelDiagController method assertMultivaluePolyString.

private void assertMultivaluePolyString(String message, String[] expectedOrigs, Collection<PolyString> actualPolyStrings, OperationResult result) {
    if (expectedOrigs.length != actualPolyStrings.size()) {
        fail(message + ": expected " + expectedOrigs.length + " values but has " + actualPolyStrings.size() + " values: " + actualPolyStrings, result);
        return;
    }
    for (String expectedOrig : expectedOrigs) {
        boolean found = false;
        for (PolyString actualPolyString : actualPolyStrings) {
            if (expectedOrig.equals(actualPolyString.getOrig())) {
                found = true;
                assertEquals(message + ", norm", polyStringNorm(expectedOrig), actualPolyString.getNorm(), result);
                break;
            }
        }
        if (!found) {
            fail(message + ": expected value '" + expectedOrig + "' not found in actual values " + actualPolyStrings, result);
            return;
        }
    }
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RandomString(com.evolveum.midpoint.util.RandomString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 13 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testNpeFalseToTrue.

@Test
public void testNpeFalseToTrue() throws Exception {
    final String TEST_NAME = "testNpeFalseToTrue";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Captain Sparrow");
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping("mapping-npe.xml", TEST_NAME, "title", delta);
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("15"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 14 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class PrismPropertyRealValueFromObjectWrapperModel method setObject.

@Override
public void setObject(Object object) {
    try {
        PrismProperty property = getPrismObject().findOrCreateProperty(path);
        if (object != null) {
            PrismPropertyDefinition def = property.getDefinition();
            if (PolyString.class.equals(def.getTypeClass())) {
                object = new PolyString((String) object);
            }
            property.setValue(new PrismPropertyValue(object, OriginType.USER_ACTION, null));
        } else {
            PrismContainerValue parent = (PrismContainerValue) property.getParent();
            parent.remove(property);
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't update prism property model", ex);
    }
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 15 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class AbstractLexicalProcessorTest method assertResourceRum.

private void assertResourceRum(PrismObject<ResourceType> resource) throws SchemaException {
    resource.checkConsistence();
    resource.assertDefinitions("test");
    assertEquals("Wrong oid", RESOURCE_RUM_OID, resource.getOid());
    PrismAsserts.assertObjectDefinition(resource.getDefinition(), RESOURCE_QNAME, RESOURCE_TYPE_QNAME, ResourceType.class);
    PrismAsserts.assertParentConsistency(resource);
    assertPropertyValue(resource, "name", new PolyString("Rum Delivery System", "rum delivery system"));
    assertPropertyDefinition(resource, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
    PrismProperty<SchemaDefinitionType> propSchema = resource.findProperty(ResourceType.F_SCHEMA);
    assertNotNull("No schema property in resource", propSchema);
    PrismPropertyDefinition<SchemaDefinitionType> propSchemaDef = propSchema.getDefinition();
    assertNotNull("No definition of schema property in resource", propSchemaDef);
    SchemaDefinitionType schemaDefinitionType = propSchema.getRealValue();
    assertNotNull("No value of schema property in resource", schemaDefinitionType);
    Element schemaElement = schemaDefinitionType.getSchema();
    assertNotNull("No schema element in schema property in resource", schemaElement);
    System.out.println("Resource schema:");
    System.out.println(DOMUtil.serializeDOMToString(schemaElement));
    assertEquals("Bad schema element name", DOMUtil.XSD_SCHEMA_ELEMENT, DOMUtil.getQName(schemaElement));
    Element complexTypeElement = DOMUtil.getChildElement(schemaElement, XSD_COMPLEX_TYPE_ELEMENT_NAME);
    assertNotNull("No complexType element in schema element in schema property in resource", complexTypeElement);
    String complexTypeName = complexTypeElement.getAttribute("name");
    assertEquals("Wrong name of complex type", "BarrelType", complexTypeName);
}
Also used : SchemaDefinitionType(com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Element(org.w3c.dom.Element) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)168 Test (org.testng.annotations.Test)103 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)90 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)67 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)53 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)44 Task (com.evolveum.midpoint.task.api.Task)41 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 QName (javax.xml.namespace.QName)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)15 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)12 ArrayList (java.util.ArrayList)12 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 File (java.io.File)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)8 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)8