use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class PrismAsserts method assertEmphasized.
public static void assertEmphasized(PrismContainerDefinition<? extends Containerable> containerDef, QName itemQName, Boolean expected) {
PrismPropertyDefinition propertyDefinition = containerDef.findPropertyDefinition(itemQName);
assertEquals("Wrong value of 'emphasized' in property '" + PrettyPrinter.prettyPrint(itemQName) + " in " + containerDef, expected, propertyDefinition.isEmphasized());
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDomain method testControlReplaceSingleValue.
/**
* Control. All goes well here. All values in the domain.
*/
@Test
public void testControlReplaceSingleValue() throws Exception {
final String TEST_NAME = "testControlReplaceSingleValue";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
List<String> employeeTypeOld = userOld.asObjectable().getEmployeeType();
employeeTypeOld.clear();
employeeTypeOld.add("1234567890");
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Jackie");
delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "321");
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(MAPPING_DOMAIN_FILENAME, TEST_NAME, "organization", delta, userOld);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (321)"));
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (1234567890)"));
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptExtraVariablesJaxb.
@Test
public void testScriptExtraVariablesJaxb() throws Exception {
// GIVEN
final String TEST_NAME = "testScriptExtraVariablesJaxb";
TestUtil.displayTestTile(TEST_NAME);
Mapping.Builder<PrismPropertyValue<String>, PrismPropertyDefinition<String>> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", TEST_NAME, "employeeType", null);
Map<QName, Object> vars = new HashMap<QName, Object>();
UserType userType = (UserType) PrismTestUtil.parseObject(new File(MidPointTestConstants.OBJECTS_DIR, "c0c010c0-d34d-b33f-f00d-111111111112.xml")).asObjectable();
vars.put(new QName(SchemaConstants.NS_C, "sailor"), userType);
builder.addVariableDefinitions(vars);
Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = builder.build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleZero(outputTriple, "Captain barbossa");
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptRootNodeRef.
@Test
public void testScriptRootNodeRef() throws Exception {
// GIVEN
final String TEST_NAME = "testScriptRootNodeRef";
TestUtil.displayTestTile(TEST_NAME);
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.<PolyString>createMappingBuilder("mapping-script-root-node.xml", TEST_NAME, "locality", null).rootNode(MiscSchemaUtil.createObjectReference("c0c010c0-d34d-b33f-f00d-111111111111", UserType.COMPLEX_TYPE)).build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleZero(outputTriple, new PolyString("Black Pearl", "black pearl"));
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testConditionNonEmptyCaptain.
@Test
public void testConditionNonEmptyCaptain() throws Exception {
// GIVEN
final String TEST_NAME = "testConditionNonEmptyCaptain";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<UserType> user = evaluator.getUserOld();
user.asObjectable().getEmployeeType().clear();
user.asObjectable().getEmployeeType().add("CAPTAIN");
ObjectDelta<UserType> delta = ObjectDelta.createAddDelta(user);
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping("mapping-condition-nonempty.xml", TEST_NAME, "title", delta);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The CAPTAIN"));
PrismAsserts.assertTripleNoMinus(outputTriple);
}
Aggregations