use of com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test810ResourceAndItsBusinessApproverReferences.
@Test
public void test810ResourceAndItsBusinessApproverReferences() throws Exception {
OperationResult result = createOperationResult();
given("resource");
String objectName = "res" + getTestNumber();
UUID connectorOid = UUID.randomUUID();
QName approver1Relation = QName.valueOf("{https://random.org/ns}random-rel-1");
QName approver2Relation = QName.valueOf("{https://random.org/ns}random-rel-2");
QName connectorRelation = QName.valueOf("{https://random.org/ns}conn-rel");
ResourceType resource = new ResourceType(prismContext).name(objectName).business(new ResourceBusinessConfigurationType(prismContext).administrativeState(ResourceAdministrativeStateType.DISABLED).approverRef(UUID.randomUUID().toString(), UserType.COMPLEX_TYPE, approver1Relation).approverRef(UUID.randomUUID().toString(), ServiceType.COMPLEX_TYPE, approver2Relation)).operationalState(new OperationalStateType().lastAvailabilityStatus(AvailabilityStatusType.BROKEN)).connectorRef(connectorOid.toString(), ConnectorType.COMPLEX_TYPE, connectorRelation);
when("adding it to the repository");
repositoryService.addObject(resource.asPrismObject(), null, result);
then("it is stored and relevant attributes are in columns");
assertThatOperationResult(result).isSuccess();
MResource row = selectObjectByOid(QResource.class, resource.getOid());
assertThat(row.businessAdministrativeState).isEqualTo(ResourceAdministrativeStateType.DISABLED);
assertThat(row.operationalStateLastAvailabilityStatus).isEqualTo(AvailabilityStatusType.BROKEN);
assertThat(row.connectorRefTargetOid).isEqualTo(connectorOid);
assertThat(row.connectorRefTargetType).isEqualTo(MObjectType.CONNECTOR);
assertCachedUri(row.connectorRefRelationId, connectorRelation);
QObjectReference<?> ref = QObjectReferenceMapping.getForResourceBusinessConfigurationApprover().defaultAlias();
List<MReference> refs = select(ref, ref.ownerOid.eq(row.oid));
assertThat(refs).hasSize(2);
refs.sort(comparing(rr -> rr.targetType));
MReference refRow = refs.get(0);
assertThat(refRow.referenceType).isEqualTo(MReferenceType.RESOURCE_BUSINESS_CONFIGURATION_APPROVER);
assertThat(refRow.targetType).isEqualTo(MObjectType.SERVICE);
assertCachedUri(refRow.relationId, approver2Relation);
}
Aggregations