use of com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test821ArchetypeAndInducement.
// This covers mapping of attributes in AbstractRole + Archetype + inducement mapping.
// There is no focus on QFocusMapping that is covered above.
@Test
public void test821ArchetypeAndInducement() throws Exception {
OperationResult result = createOperationResult();
given("archetype object");
String objectName = "arch" + getTestNumber();
ArchetypeType archetype = new ArchetypeType(prismContext).name(objectName).autoassign(new AutoassignSpecificationType().enabled(true)).displayName("display-name").identifier("identifier").requestable(false).riskLevel("extremely-high").inducement(new AssignmentType(prismContext).order(2).targetRef(UUID.randomUUID().toString(), RoleType.COMPLEX_TYPE)).inducement(new AssignmentType(prismContext).order(3).targetRef(UUID.randomUUID().toString(), RoleType.COMPLEX_TYPE));
// this is no additional attribute specific for archetype
when("adding it to the repository");
repositoryService.addObject(archetype.asPrismObject(), null, result);
then("it is stored and relevant attributes are in columns");
assertThatOperationResult(result).isSuccess();
UUID archetypeOid = UUID.fromString(archetype.getOid());
MArchetype row = selectObjectByOid(QArchetype.class, archetypeOid);
// all attributes from MAbstractRole
assertThat(row.autoAssignEnabled).isTrue();
assertThat(row.displayNameOrig).isEqualTo("display-name");
assertThat(row.displayNameNorm).isEqualTo("displayname");
assertThat(row.identifier).isEqualTo("identifier");
assertThat(row.requestable).isFalse();
assertThat(row.riskLevel).isEqualTo("extremely-high");
QAssignment<?> a = QAssignmentMapping.getAssignmentMapping().defaultAlias();
assertThat(select(a, a.ownerOid.eq(archetypeOid))).hasSize(2).anyMatch(ar -> ar.orderValue.equals(2)).anyMatch(ar -> ar.orderValue.equals(3)).allMatch(ar -> ar.targetRefTargetOid != null && ar.targetRefTargetType == MObjectType.ROLE);
}
Aggregations