use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionTrueToFalse.
public void testScriptSystemVariablesConditionTrueToFalse(String filename) throws Exception {
// GIVEN
final String TEST_NAME = "testScriptSystemVariablesConditionTrueToFalse";
System.out.println("===[ " + TEST_NAME + "]===");
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("name"), evaluator.getPrismContext(), "Jack");
delta.addModificationDeleteProperty(evaluator.toPath("employeeType"), "CAPTAIN");
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
user.asObjectable().getEmployeeType().add("CAPTAIN");
mapping.getSourceContext().recompute();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Captain jack"));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestExpressionUtil method createVariablesOdo.
private ExpressionVariables createVariablesOdo() throws SchemaException, IOException {
ExpressionVariables variables = new ExpressionVariables();
PrismObject<UserType> userOld = createUser();
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, userOld.getOid(), UserType.F_FULL_NAME, PrismTestUtil.getPrismContext(), PrismTestUtil.createPolyString("Captain Jack Sparrow"));
ObjectDeltaObject<UserType> odo = new ObjectDeltaObject<UserType>(userOld, delta, null);
odo.recompute();
variables.addVariableDefinition(ExpressionConstants.VAR_USER, odo);
return variables;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestExpressionFunctions method testGetExtensionPropertyValueNotPresent.
@Test
public void testGetExtensionPropertyValueNotPresent() throws Exception {
final String TEST_NAME = "testGetExtensionPropertyValueNotPresent";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
PrismObject<UserType> userJack = PrismTestUtil.parseObject(USER_JACK_FILE);
// WHEN
String extensionVal = f.getExtensionPropertyValue(userJack.asObjectable(), new QName(SchemaTestConstants.NS_EXTENSION, "kajdsfhklfdsjh"));
// THEN
assertNull("Unexpected value for extension " + SchemaTestConstants.EXTENSION_SHIP_ELEMENT + ": " + extensionVal, extensionVal);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignments.
public static <F extends FocusType> void assertAssignments(PrismObject<F> user, Class expectedType, int expectedNumber) {
F userType = user.asObjectable();
int actualAssignments = 0;
List<AssignmentType> assignments = userType.getAssignment();
for (AssignmentType assignment : assignments) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
QName type = targetRef.getType();
if (type != null) {
Class<? extends ObjectType> assignmentTargetClass = ObjectTypes.getObjectTypeFromTypeQName(type).getClassDefinition();
if (expectedType.isAssignableFrom(assignmentTargetClass)) {
actualAssignments++;
}
}
}
}
assertEquals("Unexepected number of assignments of type " + expectedType + " in " + user + ": " + userType.getAssignment(), expectedNumber, actualAssignments);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignedResource.
public static <F extends FocusType> void assertAssignedResource(PrismObject<F> user, String resourceOid) {
F userType = user.asObjectable();
for (AssignmentType assignmentType : userType.getAssignment()) {
if (assignmentType.getConstruction() == null) {
continue;
}
ObjectReferenceType targetRef = assignmentType.getConstruction().getResourceRef();
if (targetRef != null) {
if (resourceOid.equals(targetRef.getOid())) {
return;
}
}
}
AssertJUnit.fail(user + " does NOT have assigned resource " + resourceOid + " while expecting it");
}
Aggregations