use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class AssignmentProcessor method addReferences.
private void addReferences(Collection<PrismReferenceValue> extractedReferences, Collection<PrismReferenceValue> references) {
for (PrismReferenceValue reference : references) {
boolean found = false;
for (PrismReferenceValue exVal : extractedReferences) {
if (exVal.getOid().equals(reference.getOid()) && ObjectTypeUtil.relationsEquivalent(exVal.getRelation(), reference.getRelation())) {
found = true;
break;
}
}
if (!found) {
// using copyObject=false instead of calling canonicalize()
PrismReferenceValue ref = reference.clone(false);
if (ref.getRelation() != null && QNameUtil.isUnqualified(ref.getRelation())) {
ref.setRelation(new QName(SchemaConstants.NS_ORG, ref.getRelation().getLocalPart(), SchemaConstants.PREFIX_NS_ORG));
}
extractedReferences.add(ref);
}
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class RoleMemberPanel method createReferenceValuesList.
private List<PrismReferenceValue> createReferenceValuesList() {
List<PrismReferenceValue> referenceValuesList = new ArrayList<>();
if (relations != null && relations.size() > 0) {
for (RelationTypes relation : relations) {
PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
rv.setRelation(relation.getRelation());
referenceValuesList.add(rv);
}
} else {
PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
referenceValuesList.add(rv);
}
return referenceValuesList;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PrismAsserts method assertHasTargetName.
public static void assertHasTargetName(PrismContainerValue<?> pcv, ItemPath path) {
for (PrismValue value : getValues(pcv, path)) {
PrismReferenceValue prv = (PrismReferenceValue) value;
assertHasTargetName(prv);
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PrismAsserts method assertHasNoTargetName.
public static void assertHasNoTargetName(PrismContainerValue<?> pcv, ItemPath path) {
for (PrismValue value : getValues(pcv, path)) {
PrismReferenceValue prv = (PrismReferenceValue) value;
assertHasNoTargetName(prv);
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestAssignmentProcessor2 method test050JackDeputyOfBarbossa.
/**
* MMR1 -----------I------------------------------*
* ^ |
* | I
* | V
* MR1 -----------I-------------*-----> MR3 MR4
* ^ MR2 --I---* | | |
* | ^ I I I I
* | | V V V V
* R1 --I--> R2 O3 R4 R5 R6
* ^
* |
* |
* jack --D--> barbossa
*
* (D = deputy assignment)
*
*/
@Test(enabled = FIRST_PART)
public void test050JackDeputyOfBarbossa() throws Exception {
final String TEST_NAME = "test050JackDeputyOfBarbossa";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType policyRuleAssignment = new AssignmentType(prismContext);
PolicyRuleType rule = new PolicyRuleType(prismContext);
rule.setName("barbossa-0");
policyRuleAssignment.setPolicyRule(rule);
@SuppressWarnings({ "unchecked", "raw" }) ObjectDelta<ObjectType> objectDelta = (ObjectDelta<ObjectType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(ROLE_R1_OID, ObjectTypes.ROLE, prismContext), policyRuleAssignment).asObjectDelta(USER_BARBOSSA_OID);
executeChangesAssertSuccess(objectDelta, null, task, result);
display("barbossa", getUser(USER_BARBOSSA_OID));
objects.add(getUser(USER_BARBOSSA_OID).asObjectable());
LensContext<UserType> context = createContextForAssignment(UserType.class, USER_JACK_OID, UserType.class, USER_BARBOSSA_OID, SchemaConstants.ORG_DEPUTY, null, result);
// WHEN
assignmentProcessor.processAssignmentsProjections(context, clock.currentTimeXMLGregorianCalendar(), task, result);
// THEN
display("Output context", context);
display("Evaluated assignment triple", context.getEvaluatedAssignmentTriple());
result.computeStatus();
assertSuccess("Assignment processor failed (result)", result);
Collection<EvaluatedAssignmentImpl<UserType>> evaluatedAssignments = assertAssignmentTripleSetSize(context, 0, 1, 0);
EvaluatedAssignmentImpl<UserType> evaluatedAssignment = evaluatedAssignments.iterator().next();
assertEquals("Wrong evaluatedAssignment.isValid", true, evaluatedAssignment.isValid());
assertTargets(evaluatedAssignment, true, "R1 R2 O3 R4 R5 R6", null, null, null, null, null);
assertTargets(evaluatedAssignment, false, "barbossa MR1 MR2 MR3 MR4 MMR1", null, null, null, null, null);
assertMembershipRef(evaluatedAssignment, "");
assertOrgRef(evaluatedAssignment, "O3");
assertDelegation(evaluatedAssignment, "barbossa R1 R2 O3 R4 R5 R6");
PrismReferenceValue barbossaRef = evaluatedAssignment.getDelegationRefVals().stream().filter(v -> USER_BARBOSSA_OID.equals(v.getOid())).findFirst().orElseThrow(() -> new AssertionError("No barbossa ref in delegation ref vals"));
assertEquals("Wrong relation for barbossa delegation", SchemaConstants.ORG_DEPUTY, barbossaRef.getRelation());
// Constructions are named "role-level". We expect e.g. that from R1 we get a construction induced with order=1 (R1-1).
String expectedItems = "R1-1 R2-1 O3-1 R4-1 R5-1 R6-1 MR1-2 MR2-2 MR3-2 MR4-2 MMR1-3";
assertConstructions(evaluatedAssignment, "Brethren_account_construction Undead_monkey_account_construction " + expectedItems, null, null, null, null, null);
assertFocusMappings(evaluatedAssignment, expectedItems);
assertFocusPolicyRules(evaluatedAssignment, "barbossa-0 " + expectedItems);
// Rules for other targets are empty, which is very probably OK. All rules are bound to target "barbossa".
// There is no alternative target, as barbossa does not induce anything.
assertTargetPolicyRules(evaluatedAssignment, "barbossa-0 R1-1 R2-1 MR2-2 O3-1 MR1-2 MR3-2 R5-1 R4-1 MMR1-3 MR4-2 R6-1", "");
assertAuthorizations(evaluatedAssignment, "R1 R2 O3 R4 R5 R6");
assertGuiConfig(evaluatedAssignment, "R1 R2 O3 R4 R5 R6");
}
Aggregations