use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.
the class TestProjector method test100AddAccountToJackDirect.
@Test
public void test100AddAccountToJackDirect() throws Exception {
final String TEST_NAME = "test100AddAccountToJackDirect";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjector.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
LensContext<UserType> context = createUserLensContext();
fillContextWithUser(context, USER_JACK_OID, result);
// We want "shadow" so the fullname will be computed by outbound expression
addModificationToContextAddAccountFromFile(context, ACCOUNT_SHADOW_JACK_DUMMY_FILE);
display("Input context", context);
assertFocusModificationSanity(context);
rememberShadowFetchOperationCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
projector.project(context, "test", task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Output context", context);
// Not loading anything. The account is already loaded in the context
assertShadowFetchOperationCountIncrement(0);
assertNull("Unexpected user primary changes " + context.getFocusContext().getPrimaryDelta(), context.getFocusContext().getPrimaryDelta());
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();
assertEquals("Wrong policy decision", SynchronizationPolicyDecision.ADD, accContext.getSynchronizationPolicyDecision());
ObjectDelta<ShadowType> accountPrimaryDelta = accContext.getPrimaryDelta();
assertEquals(ChangeType.ADD, accountPrimaryDelta.getChangeType());
PrismObject<ShadowType> accountToAddPrimary = accountPrimaryDelta.getObjectToAdd();
assertNotNull("No object in account primary add delta", accountToAddPrimary);
PrismProperty<Object> intentProperty = accountToAddPrimary.findProperty(ShadowType.F_INTENT);
assertNotNull("No account type in account primary add delta", intentProperty);
assertEquals(DEFAULT_INTENT, intentProperty.getRealValue());
assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "AccountObjectClass"), accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue());
PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF);
assertEquals(getDummyResourceType().getOid(), resourceRef.getOid());
accountToAddPrimary.checkConsistence();
ObjectDelta<ShadowType> accountSecondaryDelta = accContext.getSecondaryDelta();
assertEquals(ChangeType.MODIFY, accountSecondaryDelta.getChangeType());
PropertyDelta<String> fullNameDelta = accountSecondaryDelta.findPropertyDelta(getDummyResourceController().getAttributeFullnamePath());
PrismAsserts.assertReplace(fullNameDelta, "Jack Sparrow");
PrismAsserts.assertOrigin(fullNameDelta, OriginType.OUTBOUND);
PrismObject<ShadowType> accountNew = accContext.getObjectNew();
IntegrationTestTools.assertIcfsNameAttribute(accountNew, "jack");
IntegrationTestTools.assertAttribute(accountNew, getDummyResourceController().getAttributeFullnameQName(), "Jack Sparrow");
IntegrationTestTools.assertAttribute(accountNew, getDummyResourceController().getAttributeWeaponQName(), "mouth", "pistol");
}
Aggregations