use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testInboundMapping.
@Test
public void testInboundMapping() throws Exception {
final String TEST_NAME = "testInboundMapping";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<ShadowType> account = PrismTestUtil.parseObject(new File(MappingTestEvaluator.TEST_DIR + "/account-inbound-mapping.xml"));
Item oldItem = account.findItem(new ItemPath(ShadowType.F_ATTRIBUTES, SchemaTestConstants.ICFS_NAME));
ItemDelta delta = PropertyDelta.createModificationAddProperty(SchemaTestConstants.ICFS_NAME_PATH, (PrismPropertyDefinition) oldItem.getDefinition(), ((PrismPropertyValue) oldItem.getValue(0)).getValue());
PrismObject<UserType> user = evaluator.getUserDefinition().instantiate();
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createInboudMapping("mapping-inbound.xml", TEST_NAME, delta, user.asObjectable(), account.asObjectable(), null, null);
OperationResult opResult = new OperationResult(TEST_NAME);
mapping.evaluate(null, opResult);
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
assertTripleZero(outputTriple, PrismTestUtil.createPolyString("pavolr"));
PrismAsserts.assertTripleNoPlus(outputTriple);
assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testGenerateProtectedString.
@Test
public void testGenerateProtectedString() throws Exception {
final String TEST_NAME = "testGenerateProtectedString";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Mapping<PrismPropertyValue<ProtectedStringType>, PrismPropertyDefinition<ProtectedStringType>> mapping = evaluator.createMapping("mapping-generate.xml", TEST_NAME, SchemaConstants.PATH_PASSWORD_VALUE, null);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<ProtectedStringType>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
ProtectedStringType value1 = MappingTestEvaluator.getSingleValue("plus set", outputTriple.getZeroSet());
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
System.out.println("Generated excrypted value: " + value1);
assertNotNull(value1);
assertNotNull(value1.getEncryptedDataType());
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testConditionNonEmptyEmpty.
@Test
public void testConditionNonEmptyEmpty() throws Exception {
// GIVEN
final String TEST_NAME = "testConditionNonEmptyEmpty";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<UserType> user = evaluator.getUserOld();
user.asObjectable().getEmployeeType().clear();
user.asObjectable().getEmployeeType().add("");
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();
assertNull("Unexpected value in outputTriple", outputTriple);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptExtraVariablesRef.
@Test
public void testScriptExtraVariablesRef() throws Exception {
// GIVEN
Mapping.Builder<PrismPropertyValue<String>, PrismPropertyDefinition<String>> builder = evaluator.createMappingBuilder("mapping-script-extra-variables.xml", "testScriptExtraVariablesRef", "employeeType", null);
Map<QName, Object> vars = new HashMap<QName, Object>();
ObjectReferenceType ref = MiscSchemaUtil.createObjectReference("c0c010c0-d34d-b33f-f00d-111111111112", UserType.COMPLEX_TYPE);
vars.put(new QName(SchemaConstants.NS_C, "sailor"), ref);
builder.addVariableDefinitions(vars);
Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = builder.build();
OperationResult opResult = new OperationResult("testScriptExtraVariablesRef");
// 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 TestMappingDynamicSysVar method employeeTypeDeltaABAdd.
public PrismValueDeltaSetTriple<PrismPropertyValue<String>> employeeTypeDeltaABAdd(final String TEST_NAME, String addVal, String... oldVals) throws Exception {
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), addVal);
Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = evaluator.createMapping("mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta);
PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
setEmployeeType(user.asObjectable(), oldVals);
mapping.getSourceContext().recompute();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
evaluator.assertResult(opResult);
return mapping.getOutputTriple();
}
Aggregations