Search in sources :

Example 56 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class TestClockwork method assertJackAssignAccountContext.

private void assertJackAssignAccountContext(LensContext<UserType> context) {
    assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
    if (context.getFocusContext().getSecondaryDelta() != null) {
        assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    }
    assertFalse("No account changes", context.getProjectionContexts().isEmpty());
    Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
    assertEquals(1, accountContexts.size());
    LensProjectionContext accContext = accountContexts.iterator().next();
    assertNull("Account primary delta sneaked in", accContext.getPrimaryDelta());
    assertEquals(SynchronizationPolicyDecision.KEEP, accContext.getSynchronizationPolicyDecision());
    ObjectDelta<?> executedDelta = getExecutedDelta(accContext);
    assertNotNull("No executed delta in " + accContext, executedDelta);
    assertEquals(ChangeType.ADD, executedDelta.getChangeType());
    PrismAsserts.assertPropertyAdd(executedDelta, getIcfsNameAttributePath(), "jack");
    PrismAsserts.assertPropertyAdd(executedDelta, getDummyResourceController().getAttributeFullnamePath(), "Jack Sparrow");
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext)

Example 57 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class TestClockwork method assertJackAccountShadow.

private void assertJackAccountShadow(LensContext<UserType> context) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
    assertEquals(1, accountContexts.size());
    LensProjectionContext accContext = accountContexts.iterator().next();
    String accountOid = accContext.getOid();
    assertNotNull("No OID in account context " + accContext);
    PrismObject<ShadowType> newAccount = getShadowModel(accountOid);
    assertEquals(DEFAULT_INTENT, newAccount.findProperty(ShadowType.F_INTENT).getRealValue());
    assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "AccountObjectClass"), newAccount.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue());
    PrismReference resourceRef = newAccount.findReference(ShadowType.F_RESOURCE_REF);
    assertEquals(getDummyResourceType().getOid(), resourceRef.getOid());
    PrismContainer<?> attributes = newAccount.findContainer(ShadowType.F_ATTRIBUTES);
    assertEquals("jack", attributes.findProperty(SchemaTestConstants.ICFS_NAME).getRealValue());
    assertEquals("Jack Sparrow", attributes.findProperty(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "fullname")).getRealValue());
}
Also used : QName(javax.xml.namespace.QName) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) PrismReference(com.evolveum.midpoint.prism.PrismReference)

Example 58 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class TestDependencies method test100SortToWavesIdependent.

@Test
public void test100SortToWavesIdependent() throws Exception {
    final String TEST_NAME = "test100SortToWavesIdependent";
    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);
    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 59 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class TestDependencies method test202SortToWavesABCDDeprovision.

@Test
public void test202SortToWavesABCDDeprovision() throws Exception {
    final String TEST_NAME = "test202SortToWavesABCDDeprovision";
    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));
    setDelete(fillContextWithDummyElaineAccount(context, "c", task, result));
    setDelete(fillContextWithDummyElaineAccount(context, "d", 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, 2);
    assertWave(context, getDummyOid("b"), 0, 1);
    assertWave(context, getDummyOid("c"), 0, 0);
    assertWave(context, getDummyOid("d"), 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 60 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class ProfilingLensDebugListener method afterProjection.

@Override
public <F extends ObjectType> void afterProjection(LensContext<F> context) {
    projectorEndTime = System.currentTimeMillis();
    String desc = null;
    if (context.getFocusContext() != null) {
        PrismObject<F> focusObject = context.getFocusContext().getObjectNew();
        if (focusObject == null) {
            context.getFocusContext().getObjectOld();
        }
        if (focusObject != null) {
            desc = focusObject.toString();
        }
    } else {
        for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
            PrismObject<ShadowType> projObj = projectionContext.getObjectNew();
            if (projObj == null) {
                projObj = projectionContext.getObjectOld();
            }
            if (projObj != null) {
                desc = projObj.toString();
                break;
            }
        }
    }
    int changes = 0;
    Collection<ObjectDelta<? extends ObjectType>> allDeltas = null;
    try {
        allDeltas = context.getAllChanges();
    } catch (SchemaException e) {
        changes = -1;
    }
    if (allDeltas != null) {
        changes = allDeltas.size();
    }
    long projectorEtime = projectorEndTime - projectorStartTime;
    LOGGER.trace("Projector finished ({}), {} changes, etime: {} ms ({} mapping evaluated, {} ms total)", new Object[] { desc, changes, projectorEtime, projectorMappingTotalCount, projectorMappingTotalMillis });
    lastLensContext = context;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

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