Search in sources :

Example 1 with MTask

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

the class SqaleRepoModifyObjectTest method test205SetNestedMetadataContainerWithReplace.

@Test
public void test205SetNestedMetadataContainerWithReplace() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    given("delta with metadata change for task 1 replacing value");
    UUID creatorRefOid = UUID.randomUUID();
    QName creatorRelation = QName.valueOf("{https://random.org/ns}modifier-rel");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(ObjectType.F_METADATA).replace(new MetadataType().createChannel("any://create-channel").modifyChannel("any://modify2-channel").creatorRef(creatorRefOid.toString(), UserType.COMPLEX_TYPE, creatorRelation)).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://create-channel");
    assertThat(taskObject.getMetadata().getModifyChannel()).isEqualTo("any://modify2-channel");
    // details checked in row
    assertThat(taskObject.getMetadata().getCreatorRef()).isNotNull();
    assertThat(taskObject.getMetadata().getModifierRef()).isNull();
    and("externalized column is updated");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertCachedUri(row.createChannelId, "any://create-channel");
    assertThat(row.creatorRefTargetOid).isEqualTo(creatorRefOid);
    assertThat(row.creatorRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(row.creatorRefRelationId, creatorRelation);
    assertCachedUri(row.modifyChannelId, "any://modify2-channel");
    assertThat(row.modifierRefTargetOid).isNull();
    assertThat(row.modifierRefTargetType).isNull();
    assertThat(row.modifierRefRelationId).isNull();
}
Also used : MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 2 with MTask

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

the class SqaleRepoModifyObjectTest method test147DeleteEnumAttribute.

@Test
public void test147DeleteEnumAttribute() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    given("delta with execution status replace to null ('delete') for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(TaskType.F_EXECUTION_STATE).replace().asObjectDelta(task1Oid);
    and("task row previously having the handler URI value");
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    assertThat(originalRow.executionState).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 and execution status is gone");
    TaskType taskObject = repositoryService.getObject(TaskType.class, task1Oid, null, result).asObjectable();
    assertThat(taskObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(taskObject.getExecutionState()).isNull();
    and("externalized column is set to NULL");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.executionState).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 3 with MTask

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

the class SqaleRepoModifyObjectTest method test202ChangeNestedMetadataAttributeWithReplaceModification.

@Test
public void test202ChangeNestedMetadataAttributeWithReplaceModification() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    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).replace("any://channel").asObjectDelta(task1Oid);
    and("task row previously having no value in createChannelId (is null)");
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    assertThat(originalRow.createChannelId).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 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 4 with MTask

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

the class SqaleRepoModifyObjectTest method test206SetNestedMetadataWithEmptyContainer.

@Test
public void test206SetNestedMetadataWithEmptyContainer() 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(new MetadataType()).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()).isNotNull().matches(m -> m.asPrismContainerValue().isEmpty());
    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 5 with MTask

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

the class SqaleRepoModifyObjectTest method test144DeleteCachedUriAttribute.

@Test
public void test144DeleteCachedUriAttribute() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    given("delta with handler replace to null ('delete') for task 1");
    ObjectDelta<TaskType> delta = prismContext.deltaFor(TaskType.class).item(TaskType.F_HANDLER_URI).replace().asObjectDelta(task1Oid);
    and("task row previously having the handler URI value");
    MTask originalRow = selectObjectByOid(QTask.class, task1Oid);
    assertThat(originalRow.handlerUriId).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 and handler URI is gone");
    TaskType taskObject = repositoryService.getObject(TaskType.class, task1Oid, null, result).asObjectable();
    assertThat(taskObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(taskObject.getHandlerUri()).isNull();
    and("externalized column is set to NULL");
    MTask row = selectObjectByOid(QTask.class, task1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.handlerUriId).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)

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