use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test204SetNestedMetadataContainerWithAdd.
// This one is questionable, it is technically a replace and perhaps should refuse to override
// existing container but if it works on prism level, it must work on repository level too.
@Test
public void test204SetNestedMetadataContainerWithAdd() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
given("delta with metadata change for task 1 adding value");
UUID modifierRefOid = UUID.randomUUID();
QName modifierRelation = QName.valueOf("{https://random.org/ns}modifier-rel");
ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA).add(new MetadataType().modifyChannel("any://modify-channel").modifierRef(modifierRefOid.toString(), UserType.COMPLEX_TYPE, modifierRelation)).asObjectDelta(task1Oid);
and("task row previously having some value in metadata container");
MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
assertThat(originalRow.createChannelId).isNotNull();
when("modifyObject is called");
repositoryService.modifyObject(TaskType.class, task1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
TaskType taskObject = repositoryService.getObject(TaskType.class, task1Oid, null, result).asObjectable();
assertThat(taskObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
assertThat(taskObject.getMetadata().getCreateChannel()).isNull();
assertThat(taskObject.getMetadata().getModifyChannel()).isEqualTo("any://modify-channel");
// details checked in row
assertThat(taskObject.getMetadata().getModifierRef()).isNotNull();
and("externalized column is updated");
MTask row = selectObjectByOid(QTask.class, task1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
// overwritten by complete container value
assertThat(row.createChannelId).isNull();
assertCachedUri(row.modifyChannelId, "any://modify-channel");
assertThat(row.modifierRefTargetOid).isEqualTo(modifierRefOid);
assertThat(row.modifierRefTargetType).isEqualTo(MObjectType.USER);
assertCachedUri(row.modifierRefRelationId, modifierRelation);
}
Aggregations