use of com.evolveum.midpoint.prism.PrismPropertyDefinition 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.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingTime method testExistenceAfter.
@Test
public void testExistenceAfter() throws Exception {
final String TEST_NAME = "testExistenceAfter";
System.out.println("===[ " + TEST_NAME + "]===");
// GIVEN
Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null);
builder.setNow(TIME_FUTURE);
PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
builder.setDefaultTargetDefinition(existenceDef);
Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
PrismAsserts.assertTripleZero(outputTriple, false);
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
assertNextRecompute(mapping, null);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testEmployeeTypeDeltaBreplaceB.
@Test
public void testEmployeeTypeDeltaBreplaceB() throws Exception {
final String TEST_NAME = "testEmployeeTypeDeltaBreplaceB";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "B");
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(), "B");
mapping.getSourceContext().recompute();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
evaluator.assertResult(opResult);
PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = mapping.getOutputTriple();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, "B");
PrismAsserts.assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testPathEnum.
@Test
public void testPathEnum() throws Exception {
final String TEST_NAME = "testPathEnum";
System.out.println("===[ " + TEST_NAME + "]===");
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, evaluator.getPrismContext(), ActivationStatusType.DISABLED);
Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = evaluator.createMapping("mapping-path-enum.xml", TEST_NAME, "costCenter", delta);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = mapping.getOutputTriple();
System.out.println("Output triple");
System.out.println(outputTriple.debugDump());
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, ActivationStatusType.DISABLED.value());
PrismAsserts.assertTripleMinus(outputTriple, ActivationStatusType.ENABLED.value());
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition 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);
}
Aggregations