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