use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.
the class FocusAsserter method singleLink.
public ShadowReferenceAsserter<? extends FocusAsserter<F, RA>> singleLink() {
PrismReference linkRef = getObject().findReference(FocusType.F_LINK_REF);
if (linkRef == null) {
fail("Expected single link, but is no linkRef in " + desc());
// not reached
return null;
}
assertEquals("Wrong number of links in " + desc(), 1, linkRef.size());
ShadowReferenceAsserter<FocusAsserter<F, RA>> asserter = new ShadowReferenceAsserter<>(linkRef.getAnyValue(), null, this, "link in " + desc());
copySetupTo(asserter);
return asserter;
}
use of com.evolveum.midpoint.prism.PrismReference 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, accountOid);
PrismObject<ShadowType> newAccount = getShadowModel(accountOid);
assertEquals(DEFAULT_INTENT, newAccount.findProperty(ShadowType.F_INTENT).getRealValue());
getDummyResourceType();
assertEquals(new QName(MidPointConstants.NS_RI, "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());
getDummyResourceType();
assertEquals("Jack Sparrow", attributes.findProperty(new ItemName(MidPointConstants.NS_RI, "fullname")).getRealValue());
}
use of com.evolveum.midpoint.prism.PrismReference 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 {
// GIVEN
Task task = getTestTask();
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);
displayDumpable("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
displayDumpable("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 projection contexts", 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());
getDummyResourceType();
assertEquals(new QName(MidPointConstants.NS_RI, "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.prism.PrismReference in project midpoint by Evolveum.
the class TestProjector method test100AddAccountToJackDirect.
@Test
public void test100AddAccountToJackDirect() throws Exception {
// GIVEN
Task task = getTestTask();
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);
displayDumpable("Input context", context);
assertFocusModificationSanity(context);
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
projector.project(context, "test", task, result);
// THEN
then();
displayDumpable("Output context", context);
// Not loading anything. The account is already loaded in the context
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 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());
getDummyResourceType();
assertEquals(new QName(MidPointConstants.NS_RI, "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");
assertSerializable(context);
}
use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.
the class ProjectionsLoadOperation method getLinkRefDelta.
@Nullable
private ReferenceDelta getLinkRefDelta(ObjectDelta<F> focusPrimaryDelta) {
if (focusPrimaryDelta.getChangeType() == ChangeType.ADD) {
PrismReference linkRef = focusPrimaryDelta.getObjectToAdd().findReference(FocusType.F_LINK_REF);
if (linkRef == null) {
// Adding new focus with no linkRef -> nothing to do
return null;
} else {
ReferenceDelta linkRefDelta = linkRef.createDelta(FocusType.F_LINK_REF);
linkRefDelta.addValuesToAdd(PrismValueCollectionsUtil.cloneValues(linkRef.getValues()));
return linkRefDelta;
}
} else if (focusPrimaryDelta.getChangeType() == ChangeType.MODIFY) {
return focusPrimaryDelta.findReferenceModification(FocusType.F_LINK_REF);
} else {
// delete, all existing account are already marked for delete
return null;
}
}
Aggregations