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");
}
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());
}
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);
}
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);
}
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;
}
Aggregations