Search in sources :

Example 21 with MTask

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);
}
Also used : QName(javax.xml.namespace.QName) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)21 MTask (com.evolveum.midpoint.repo.sqale.qmodel.task.MTask)21 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 Test (org.testng.annotations.Test)21 QName (javax.xml.namespace.QName)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 UUID (java.util.UUID)1