Search in sources :

Example 46 with PrismReference

use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.

the class TestMapleLeaf method test001addUser.

@Test
public void test001addUser() throws Exception {
    // when
    when();
    assignAccountToUser(USER_JACK_OID, RESOURCE_OPENDJ_OID, "default");
    // then
    then();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertNotNull("User is null", user);
    assertLiveLinks(user, 1);
    PrismReference ref = user.findReference(UserType.F_LINK_REF);
    String shadowOid = ref.getOid();
    assertNotNull("Reference without oid? Something went wrong.", shadowOid);
    PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
    assertNotNull("Shadow not found", shadow);
    ResourceAttributeContainer shadowContainer = ShadowUtil.getAttributesContainer(shadow);
    ResourceAttribute<String> initials = shadowContainer.findAttribute(new QName(NS_RESOURCE, "initials"));
    assertEquals(initials.size(), 3, "Expected 3 values in attribute, but found " + initials.size());
    Collection<String> values = initials.getRealValues();
    assertTrue(values.contains("monkey"), "No monkey found among values");
    assertTrue(values.contains("donkey"), "No donkey found among values");
    assertTrue(values.contains("mcconkey"), "No mcconkey found among values");
}
Also used : QName(javax.xml.namespace.QName) PrismReference(com.evolveum.midpoint.prism.PrismReference) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) Test(org.testng.annotations.Test)

Example 47 with PrismReference

use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.

the class TestMapleLeaf method test003unassignRoleSquirrel.

@Test
public void test003unassignRoleSquirrel() throws Exception {
    // when
    when();
    unassignRole(USER_JACK_OID, ROLE_SQUIRREL_OID);
    // then
    then();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertNotNull("User is null", user);
    assertLiveLinks(user, 1);
    PrismReference ref = user.findReference(UserType.F_LINK_REF);
    String shadowOid = ref.getOid();
    assertNotNull("Reference without oid? Something went wrong.", shadowOid);
    PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
    assertNotNull("Shadow not found", shadow);
    ResourceAttributeContainer shadowContainer = ShadowUtil.getAttributesContainer(shadow);
    ResourceAttribute<String> initials = shadowContainer.findAttribute(new QName(NS_RESOURCE, "initials"));
    assertEquals(initials.size(), 3, "Expected 3 values in attribute, but found " + initials.size());
    Collection<String> values = initials.getRealValues();
    assertTrue(values.contains("monkey"), "No monkey found among values");
    assertTrue(values.contains("donkey"), "No donkey found among values");
    assertTrue(values.contains("mcconkey"), "No mcconkey found among values");
}
Also used : QName(javax.xml.namespace.QName) PrismReference(com.evolveum.midpoint.prism.PrismReference) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) Test(org.testng.annotations.Test)

Example 48 with PrismReference

use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.

the class TestMapleLeaf method test006unassignRoleMapleLeafFaculty.

@Test
public void test006unassignRoleMapleLeafFaculty() throws Exception {
    // when
    when();
    unassignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID);
    // then
    then();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertNotNull("User is null", user);
    assertLiveLinks(user, 1);
    PrismReference ref = user.findReference(UserType.F_LINK_REF);
    String shadowOid = ref.getOid();
    assertNotNull("Reference without oid? Something went wrong.", shadowOid);
    PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
    assertNotNull("Shadow not found", shadow);
    ShadowType shadowType = shadow.asObjectable();
    List<ShadowAssociationType> associations = shadowType.getAssociation();
    assertFalse(associations.isEmpty(), "Expected 2 associations, but no one exists");
    assertEquals(associations.size(), 2, "Unexpected number of associations");
    openDJController.assertUniqueMember("cn=mapleLeafGraduate,ou=groups,dc=example,dc=com", "uid=jack,ou=People,dc=example,dc=com");
    openDJController.assertUniqueMember("cn=mapleLeafGraduateLicense,ou=groups,dc=example,dc=com", "uid=jack,ou=People,dc=example,dc=com");
}
Also used : PrismReference(com.evolveum.midpoint.prism.PrismReference) Test(org.testng.annotations.Test)

Example 49 with PrismReference

use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.

the class TestMapleLeaf method test004assignRoleMapleLeafFaculty.

@Test
public void test004assignRoleMapleLeafFaculty() throws Exception {
    // when
    when();
    assignRole(USER_JACK_OID, ROLE_MAPLE_LEAF_FACULTY_OID);
    // then
    then();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertNotNull("User is null", user);
    assertLiveLinks(user, 1);
    PrismReference ref = user.findReference(UserType.F_LINK_REF);
    String shadowOid = ref.getOid();
    assertNotNull("Reference without oid? Something went wrong.", shadowOid);
    PrismObject<ShadowType> shadow = getShadowModel(shadowOid);
    assertNotNull("Shadow not found", shadow);
    ShadowType shadowType = shadow.asObjectable();
    List<ShadowAssociationType> associations = shadowType.getAssociation();
    assertFalse(associations.isEmpty(), "Expected 2 associations, but no one exists");
    assertEquals(associations.size(), 2, "Unexpected number of associations");
    openDJController.assertUniqueMember("cn=mapleLeafFaculty,ou=groups,dc=example,dc=com", "uid=jack,ou=People,dc=example,dc=com");
    openDJController.assertUniqueMember("cn=mapleLeafFacultyLicense,ou=groups,dc=example,dc=com", "uid=jack,ou=People,dc=example,dc=com");
}
Also used : PrismReference(com.evolveum.midpoint.prism.PrismReference) Test(org.testng.annotations.Test)

Example 50 with PrismReference

use of com.evolveum.midpoint.prism.PrismReference in project midpoint by Evolveum.

the class PrismContainerValueAsserter method assertRefEquals.

public <T> PrismContainerValueAsserter<C, RA> assertRefEquals(QName refName, ObjectReferenceType expected, EquivalenceStrategy strategy) {
    PrismReference ref = getPrismValue().findReference(refName);
    if (ref == null && expected == null) {
        return this;
    }
    assertNotNull("No reference " + refName.getLocalPart() + " in " + desc(), ref);
    List<PrismReferenceValue> refVals = ref.getValues();
    if (refVals.isEmpty()) {
        fail("No values in reference " + refName.getLocalPart() + " in " + desc());
    }
    if (refVals.size() > 1) {
        fail("Too many values in reference " + refName.getLocalPart() + " in " + desc());
    }
    PrismReferenceValue refVal = refVals.get(0);
    assertNotNull("null value in " + refName.getLocalPart() + " in " + desc(), refVal);
    assertTrue("Wrong " + refName.getLocalPart() + " in " + desc() + ", expected: " + expected + ", real: " + refVal, expected.asReferenceValue().equals(refVal, strategy));
    return this;
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference)

Aggregations

PrismReference (com.evolveum.midpoint.prism.PrismReference)55 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)18 Test (org.testng.annotations.Test)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)12 PrismObject (com.evolveum.midpoint.prism.PrismObject)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 QName (javax.xml.namespace.QName)10 Task (com.evolveum.midpoint.task.api.Task)9 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)8 ArrayList (java.util.ArrayList)8 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)5 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)5 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)3 Item (com.evolveum.midpoint.prism.Item)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3