use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestProjectorRoleEntitlement method test100AddEntitlementToPirateDirect.
/**
* Add direct entitlement assignment to role "pirate". The entitlement projection
* context should appear in the lens context.
*/
@Test
public void test100AddEntitlementToPirateDirect() throws Exception {
final String TEST_NAME = "test100AddEntitlementToPirateDirect";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjectorRoleEntitlement.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
LensContext<RoleType> context = createLensContext(RoleType.class);
fillContextWithFocus(context, RoleType.class, ROLE_PIRATE_OID, result);
// We want "shadow" so the fullname will be computed by outbound expression
addModificationToContextAddProjection(context, RoleType.class, ENTITLEMENT_SHADOW_PIRATE_DUMMY_FILE);
display("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
display("Output context", context);
assertNull("Unexpected focus primary changes " + context.getFocusContext().getPrimaryDelta(), context.getFocusContext().getPrimaryDelta());
assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "focus secondary delta", ActivationStatusType.ENABLED);
assertFalse("No entitlement changes", context.getProjectionContexts().isEmpty());
Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
assertEquals(1, accountContexts.size());
LensProjectionContext projContext = accountContexts.iterator().next();
assertEquals("Wrong policy decision", SynchronizationPolicyDecision.ADD, projContext.getSynchronizationPolicyDecision());
ObjectDelta<ShadowType> accountPrimaryDelta = projContext.getPrimaryDelta();
assertEquals(ChangeType.ADD, accountPrimaryDelta.getChangeType());
PrismObject<ShadowType> accountToAddPrimary = accountPrimaryDelta.getObjectToAdd();
assertNotNull("No object in projection primary add delta", accountToAddPrimary);
PrismProperty<Object> intentProperty = accountToAddPrimary.findProperty(ShadowType.F_INTENT);
assertNotNull("No intent type in projection primary add delta", intentProperty);
assertEquals("group", intentProperty.getRealValue());
assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "GroupObjectClass"), accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue());
PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF);
assertEquals(getDummyResourceType().getOid(), resourceRef.getOid());
accountToAddPrimary.checkConsistence();
ObjectDelta<ShadowType> projSecondaryDelta = projContext.getSecondaryDelta();
assertEquals(ChangeType.MODIFY, projSecondaryDelta.getChangeType());
PropertyDelta<String> groupDescriptionDelta = projSecondaryDelta.findPropertyDelta(getDummyResourceController().getAttributePath(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION));
assertNotNull("No group description delta", groupDescriptionDelta);
PrismAsserts.assertReplace(groupDescriptionDelta, "Bloody pirates");
PrismAsserts.assertOrigin(groupDescriptionDelta, OriginType.OUTBOUND);
PrismObject<ShadowType> projectionNew = projContext.getObjectNew();
IntegrationTestTools.assertIcfsNameAttribute(projectionNew, "pirate");
IntegrationTestTools.assertAttribute(projectionNew, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_GROUP_ATTRIBUTE_DESCRIPTION), "Bloody pirates");
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestDependencies method test101SortToWavesAB.
@Test
public void test101SortToWavesAB() throws Exception {
final String TEST_NAME = "test101SortToWavesAB";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
LensContext<UserType> context = createUserLensContext();
LensFocusContext<UserType> focusContext = fillContextWithUser(context, USER_ELAINE_OID, result);
LensProjectionContext accountContext = fillContextWithAccount(context, ACCOUNT_SHADOW_ELAINE_DUMMY_OID, task, result);
fillContextWithDummyElaineAccount(context, "a", task, result);
fillContextWithDummyElaineAccount(context, "b", task, result);
context.recompute();
display("Context before", context);
context.checkConsistence();
// WHEN
dependencyProcessor.sortProjectionsToWaves(context);
// THEN
display("Context after", context);
assertWave(context, RESOURCE_DUMMY_OID, 0, 0);
assertWave(context, getDummyOid("a"), 0, 0);
assertWave(context, getDummyOid("b"), 0, 1);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestDependencies method test200SortToWavesIdependentDeprovision.
@Test
public void test200SortToWavesIdependentDeprovision() throws Exception {
final String TEST_NAME = "test200SortToWavesIdependentDeprovision";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
LensContext<UserType> context = createUserLensContext();
LensFocusContext<UserType> focusContext = fillContextWithUser(context, USER_ELAINE_OID, result);
LensProjectionContext accountContext = fillContextWithAccount(context, ACCOUNT_SHADOW_ELAINE_DUMMY_OID, task, result);
setDelete(accountContext);
setDelete(fillContextWithDummyElaineAccount(context, "a", task, result));
context.recompute();
display("Context before", context);
context.checkConsistence();
// WHEN
dependencyProcessor.sortProjectionsToWaves(context);
// THEN
display("Context after", context);
assertWave(context, RESOURCE_DUMMY_OID, 0, 0);
assertWave(context, getDummyOid("a"), 0, 0);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestDependencies method test201SortToWavesABDeprovision.
@Test
public void test201SortToWavesABDeprovision() throws Exception {
final String TEST_NAME = "test201SortToWavesABDeprovision";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDependencies.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
LensContext<UserType> context = createUserLensContext();
LensFocusContext<UserType> focusContext = fillContextWithUser(context, USER_ELAINE_OID, result);
LensProjectionContext accountContext = fillContextWithAccount(context, ACCOUNT_SHADOW_ELAINE_DUMMY_OID, task, result);
setDelete(accountContext);
setDelete(fillContextWithDummyElaineAccount(context, "a", task, result));
setDelete(fillContextWithDummyElaineAccount(context, "b", task, result));
context.recompute();
display("Context before", context);
context.checkConsistence();
// WHEN
dependencyProcessor.sortProjectionsToWaves(context);
// THEN
display("Context after", context);
assertWave(context, RESOURCE_DUMMY_OID, 0, 0);
assertWave(context, getDummyOid("a"), 0, 1);
assertWave(context, getDummyOid("b"), 0, 0);
}
use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.
the class TestDependencies method assertWave.
private void assertWave(LensContext<UserType> context, String resourceOid, int order, int expectedWave) {
LensProjectionContext ctxAccDummy = findAccountContext(context, resourceOid, order);
assertNotNull("No context for " + resourceOid + ", order=" + order, ctxAccDummy);
assertWave(ctxAccDummy, expectedWave);
}
Aggregations