Search in sources :

Example 1 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test121DeleteBooleanAttribute.

@Test
public void test121DeleteBooleanAttribute() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    given("delta with dead boolean replace to null for shadow 1");
    ObjectDelta<ShadowType> delta = prismContext.deltaFor(ShadowType.class).item(ShadowType.F_DEAD).replace().asObjectDelta(shadow1Oid);
    and("shadow row previously having the display order value");
    MShadow originalRow = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(originalRow.dead).isNotNull();
    when("modifyObject is called");
    repositoryService.modifyObject(ShadowType.class, shadow1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated and dead is null");
    ShadowType shadowObject = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable();
    assertThat(shadowObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(shadowObject.isDead()).isNull();
    and("externalized column is set to NULL");
    MShadow row = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.dead).isNull();
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 2 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test120ChangeBooleanAttribute.

@Test
public void test120ChangeBooleanAttribute() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationResult result = createOperationResult();
    given("delta with boolean dead change for shadow 1");
    ObjectDelta<ShadowType> delta = prismContext.deltaFor(ShadowType.class).item(ShadowType.F_DEAD).add(true).asObjectDelta(shadow1Oid);
    and("shadow row previously having dead property empty (null)");
    MShadow originalRow = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(originalRow.dead).isNull();
    when("modifyObject is called");
    repositoryService.modifyObject(ShadowType.class, shadow1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated");
    ShadowType shadowObject = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable();
    assertThat(shadowObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(shadowObject.isDead()).isTrue();
    and("externalized column is updated");
    MShadow row = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.dead).isTrue();
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 3 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test320AddShadowWithAttributes.

@Test
public void test320AddShadowWithAttributes() throws ObjectAlreadyExistsException, SchemaException {
    OperationResult result = createOperationResult();
    given("shadow with both extensions and custom attributes");
    String objectName = "shadow" + getTestNumber();
    ShadowType object = new ShadowType(prismContext).name(objectName).extension(new ExtensionType(prismContext));
    ExtensionType extensionContainer = object.getExtension();
    addExtensionValue(extensionContainer, "string", "string-value");
    ShadowAttributesType attributesContainer = new ShadowAttributesHelper(object).set(new QName("https://example.com/p", "string-mv"), DOMUtil.XSD_STRING, "string-value1", "string-value2").attributesContainer();
    when("adding it to the repository");
    String returnedOid = repositoryService.addObject(object.asPrismObject(), null, result);
    then("operation is successful and both ext and attributes column store the values");
    assertThatOperationResult(result).isSuccess();
    assertThat(returnedOid).isEqualTo(object.getOid());
    MShadow row = selectObjectByOid(QShadow.class, returnedOid);
    assertThat(row.ext).isNotNull();
    assertThat(Jsonb.toMap(row.ext)).containsEntry(extensionKey(extensionContainer, "string"), "string-value");
    assertThat(row.attributes).isNotNull();
    assertThat(Jsonb.toMap(row.attributes)).containsEntry(shadowAttributeKey(attributesContainer, "string-mv"), List.of("string-value1", "string-value2"));
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 4 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test818Shadow.

@Test
public void test818Shadow() throws Exception {
    OperationResult result = createOperationResult();
    given("shadow");
    String objectName = "shadow" + getTestNumber();
    QName objectClass = QName.valueOf("{https://random.org/ns}shadow-object-class");
    UUID resourceRefOid = UUID.randomUUID();
    QName resourceRefRelation = QName.valueOf("{https://random.org/ns}resource-ref-rel");
    ShadowType shadow = new ShadowType(prismContext).name(objectName).objectClass(objectClass).resourceRef(resourceRefOid.toString(), ResourceType.COMPLEX_TYPE, resourceRefRelation).intent("intent").tag("tag").kind(ShadowKindType.ACCOUNT).dead(false).exists(true).fullSynchronizationTimestamp(MiscUtil.asXMLGregorianCalendar(1L)).pendingOperation(new PendingOperationType().attemptNumber(1)).pendingOperation(new PendingOperationType().attemptNumber(2)).primaryIdentifierValue("PID").synchronizationSituation(SynchronizationSituationType.DISPUTED).synchronizationTimestamp(MiscUtil.asXMLGregorianCalendar(2L)).correlation(new ShadowCorrelationStateType(prismContext).correlationStartTimestamp(MiscUtil.asXMLGregorianCalendar(10L)).correlationEndTimestamp(MiscUtil.asXMLGregorianCalendar(11L)).correlationCaseOpenTimestamp(MiscUtil.asXMLGregorianCalendar(12L)).correlationCaseCloseTimestamp(MiscUtil.asXMLGregorianCalendar(13L)).situation(CorrelationSituationType.EXISTING_OWNER));
    when("adding it to the repository");
    repositoryService.addObject(shadow.asPrismObject(), null, result);
    then("it is stored and relevant attributes are in columns");
    assertThatOperationResult(result).isSuccess();
    MShadow row = selectObjectByOid(QShadow.class, shadow.getOid());
    assertCachedUri(row.objectClassId, objectClass);
    assertThat(row.resourceRefTargetOid).isEqualTo(resourceRefOid);
    assertThat(row.resourceRefTargetType).isEqualTo(MObjectType.RESOURCE);
    assertCachedUri(row.resourceRefRelationId, resourceRefRelation);
    assertThat(row.intent).isEqualTo("intent");
    assertThat(row.tag).isEqualTo("tag");
    assertThat(row.kind).isEqualTo(ShadowKindType.ACCOUNT);
    assertThat(row.dead).isEqualTo(false);
    assertThat(row.exist).isEqualTo(true);
    assertThat(row.fullSynchronizationTimestamp).isEqualTo(Instant.ofEpochMilli(1));
    assertThat(row.pendingOperationCount).isEqualTo(2);
    assertThat(row.primaryIdentifierValue).isEqualTo("PID");
    assertThat(row.synchronizationSituation).isEqualTo(SynchronizationSituationType.DISPUTED);
    assertThat(row.synchronizationTimestamp).isEqualTo(Instant.ofEpochMilli(2));
    assertThat(row.correlationStartTimestamp).isEqualTo(Instant.ofEpochMilli(10));
    assertThat(row.correlationEndTimestamp).isEqualTo(Instant.ofEpochMilli(11));
    assertThat(row.correlationCaseOpenTimestamp).isEqualTo(Instant.ofEpochMilli(12));
    assertThat(row.correlationCaseCloseTimestamp).isEqualTo(Instant.ofEpochMilli(13));
    assertThat(row.correlationSituation).isEqualTo(CorrelationSituationType.EXISTING_OWNER);
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 5 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test151PendingOperationItemModification.

@Test
public void test151PendingOperationItemModification() throws Exception {
    OperationResult result = createOperationResult();
    given("delta changing property inside existing pending operation container");
    Long cid = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable().getPendingOperation().get(0).getId();
    ObjectDelta<ShadowType> delta = prismContext.deltaFor(ShadowType.class).item(ShadowType.F_PENDING_OPERATION, cid, PendingOperationType.F_COMPLETION_TIMESTAMP).add(MiscUtil.asXMLGregorianCalendar(2L)).asObjectDelta(shadow1Oid);
    when("modifyObject is called");
    repositoryService.modifyObject(ShadowType.class, shadow1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated");
    ShadowType shadowObject = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable();
    assertThat(shadowObject.getPendingOperation()).hasSize(1);
    assertThat(shadowObject.getPendingOperation().get(0).getCompletionTimestamp()).isEqualTo(MiscUtil.asXMLGregorianCalendar(2L));
    and("externalized column is still having (the same) count");
    MShadow row = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(row.pendingOperationCount).isEqualTo(1);
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) 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)7 MShadow (com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.testng.annotations.Test)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 QName (javax.xml.namespace.QName)2 UUID (java.util.UUID)1