Search in sources :

Example 16 with MTask

use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test200ChangeNestedMetadataAttributeWithAddModification.

// endregion
// region nested (embedded) single-value containers (e.g. metadata)
@Test
public void test200ChangeNestedMetadataAttributeWithAddModification() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    given("delta with metadata/createChannel (multi-part path) change for task 1 adding value");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA, MetadataType.F_CREATE_CHANNEL).add("any://channel").asObjectDelta(task1Oid);
    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()).isEqualTo("any://channel");
    and("externalized column is updated");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertCachedUri(row.createChannelId, "any://channel");
}
Also used : 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)

Example 17 with MTask

use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test203AddingEmptyValueForNestedMetadataChangesNothing.

@Test
public void test203AddingEmptyValueForNestedMetadataChangesNothing() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    given("delta with metadata add with no value for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA).add().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("but nothing was updated (modifications narrowed to empty)");
    TaskType taskObject = repositoryService.getObject(TaskType.class, task1Oid, null, result).asObjectable();
    assertThat(taskObject.getVersion()).isEqualTo(String.valueOf(originalRow.version));
    assertThat(taskObject.getMetadata().getCreateChannel()).isEqualTo("any://channel");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version);
    assertCachedUri(row.createChannelId, "any://channel");
}
Also used : 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)

Example 18 with MTask

use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test207SettingMetadataContainerToNull.

@Test
public void test207SettingMetadataContainerToNull() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    given("delta replacing metadata with nothing for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA).replace().asObjectDelta(task1Oid);
    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()).isNull();
}
Also used : 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)

Example 19 with MTask

use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test205DeleteNestedMetadataContainerWithReplace.

@Test
public void test205DeleteNestedMetadataContainerWithReplace() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    given("delta with metadata replaced with no value for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA).replace().asObjectDelta(task1Oid);
    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()).isNull();
    and("all externalized columns for metadata are cleared");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.creatorRefTargetOid).isNull();
    assertThat(row.creatorRefTargetType).isNull();
    assertThat(row.creatorRefRelationId).isNull();
    assertThat(row.createChannelId).isNull();
    assertThat(row.createTimestamp).isNull();
    assertThat(row.modifierRefTargetOid).isNull();
    assertThat(row.modifierRefTargetType).isNull();
    assertThat(row.modifierRefRelationId).isNull();
    assertThat(row.modifyChannelId).isNull();
    assertThat(row.modifyTimestamp).isNull();
}
Also used : 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)

Example 20 with MTask

use of com.evolveum.midpoint.repo.sqale.qmodel.task.MTask in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test125ChangeTaskFullResult.

@Test
public void test125ChangeTaskFullResult() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    // This one is specific to modifiable MTask.fullResult (the one in MAuditDelta is insert-only, luckily).
    OperationResult result = createOperationResult();
    given("delta changing operation result for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(TaskType.F_RESULT).replace(new OperationResultType().message("Result message").status(OperationResultStatusType.SUCCESS)).asObjectDelta(task1Oid);
    and("test row previously having no fullResult (null)");
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    assertThat(originalRow.fullResult).isNull();
    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 task = repositoryService.getObject(TaskType.class, task1Oid, null, result).asObjectable();
    assertThat(task.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    // not stored as part of fullObject
    assertThat(task.getResult()).isNull();
    and("externalized fullResult is updated");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.fullResult).isNotNull();
    and("task with operation result can be obtained using options");
    TaskType taskWithResult = repositoryService.getObject(TaskType.class, task1Oid, retrieveGetOptions(TaskType.F_RESULT), result).asObjectable();
    assertThat(taskWithResult.getResult()).isNotNull();
}
Also used : 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