Search in sources :

Example 86 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getSingleLinkRef.

protected <F extends FocusType> PrismReferenceValue getSingleLinkRef(PrismObject<F> focus) {
    F focusType = focus.asObjectable();
    assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size());
    ObjectReferenceType linkRefType = focusType.getLinkRef().get(0);
    String accountOid = linkRefType.getOid();
    assertFalse("No linkRef oid", StringUtils.isBlank(accountOid));
    PrismReferenceValue accountRefValue = linkRefType.asReferenceValue();
    assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid());
    return accountRefValue;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 87 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method determineSynchronization.

/**
	 * Returns appropriate object synchronization settings for the class.
	 * Assumes single sync setting for now.
	 */
protected ObjectSynchronizationType determineSynchronization(ResourceType resource, Class<UserType> type, String name) {
    SynchronizationType synchronization = resource.getSynchronization();
    if (synchronization == null) {
        return null;
    }
    List<ObjectSynchronizationType> objectSynchronizations = synchronization.getObjectSynchronization();
    if (objectSynchronizations.isEmpty()) {
        return null;
    }
    for (ObjectSynchronizationType objSyncType : objectSynchronizations) {
        QName focusTypeQName = objSyncType.getFocusType();
        if (focusTypeQName == null) {
            if (type != UserType.class) {
                continue;
            }
        } else {
            ObjectTypes focusType = ObjectTypes.getObjectTypeFromTypeQName(focusTypeQName);
            if (type != focusType.getClassDefinition()) {
                continue;
            }
        }
        if (name == null) {
            // we got it
            return objSyncType;
        } else {
            if (name.equals(objSyncType.getName())) {
                return objSyncType;
            }
        }
    }
    throw new IllegalArgumentException("Synchronization setting for " + type + " and name " + name + " not found in " + resource);
}
Also used : ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) SynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationType)

Example 88 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getLinkRefOid.

protected <F extends FocusType> String getLinkRefOid(PrismObject<F> focus, String resourceOid, ShadowKindType kind, String intent) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    F focusType = focus.asObjectable();
    for (ObjectReferenceType linkRefType : focusType.getLinkRef()) {
        String linkTargetOid = linkRefType.getOid();
        assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid));
        PrismObject<ShadowType> account = getShadowModel(linkTargetOid, true, false);
        ShadowType shadowType = account.asObjectable();
        if (kind != null && !kind.equals(shadowType.getKind())) {
            continue;
        }
        if (!MiscUtil.equals(intent, shadowType.getIntent())) {
            continue;
        }
        if (resourceOid.equals(shadowType.getResourceRef().getOid())) {
            // This is noFetch. Therefore there is no fetchResult
            return linkTargetOid;
        }
    }
    AssertJUnit.fail("Linked shadow for resource " + resourceOid + ", kind " + kind + " and intent " + intent + " not found in " + focus);
    // Never reached. But compiler complains about missing return 
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 89 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class MidPointAsserts method assertAssigned.

public static void assertAssigned(PrismObject<? extends FocusType> focus, String targetOid, QName refType, QName relation) {
    FocusType focusType = focus.asObjectable();
    for (AssignmentType assignmentType : focusType.getAssignment()) {
        ObjectReferenceType targetRef = assignmentType.getTargetRef();
        if (targetRef != null) {
            if (refType.equals(targetRef.getType())) {
                if (targetOid.equals(targetRef.getOid()) && MiscSchemaUtil.compareRelation(targetRef.getRelation(), relation)) {
                    return;
                }
            }
        }
    }
    AssertJUnit.fail(focus + " does not have assigned " + refType.getLocalPart() + " " + targetOid + ", relation " + relation);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 90 with FocusType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType in project midpoint by Evolveum.

the class MidPointAsserts method assertAssignedTargets.

public static <F extends FocusType> void assertAssignedTargets(PrismObject<F> user, String typeDesc, QName type, String... expectedTargetOids) {
    F userType = user.asObjectable();
    List<String> haveTagetOids = new ArrayList<>();
    for (AssignmentType assignmentType : userType.getAssignment()) {
        ObjectReferenceType targetRef = assignmentType.getTargetRef();
        if (targetRef != null) {
            if (type.equals(targetRef.getType())) {
                haveTagetOids.add(targetRef.getOid());
            }
        }
    }
    PrismAsserts.assertSets("Wrong " + typeDesc + " in " + user, haveTagetOids, expectedTargetOids);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ArrayList(java.util.ArrayList)

Aggregations

ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)27 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 FocusType (com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 PrismObject (com.evolveum.midpoint.prism.PrismObject)16 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)15 ArrayList (java.util.ArrayList)15 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)14 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)10 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)9 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)8 QName (javax.xml.namespace.QName)8 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)7 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)7 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)7