Search in sources :

Example 66 with LensProjectionContext

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");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test)

Example 67 with LensProjectionContext

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 68 with LensProjectionContext

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 69 with LensProjectionContext

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 70 with LensProjectionContext

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);
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext)

Aggregations

LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)71 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)28 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 Task (com.evolveum.midpoint.task.api.Task)19 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)18 Test (org.testng.annotations.Test)17 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)14 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)10 MockLensDebugListener (com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)8 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)7 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)5 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)5 PrismReference (com.evolveum.midpoint.prism.PrismReference)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)5