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);
}
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;
}
}
}
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);
}
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);
}
}
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);
}
Aggregations