Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 23, 2022
2 parents 1be51e0 + 469a31a commit b772254
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package com.evolveum.midpoint.repo.sqale.update;

import java.util.LinkedHashMap;
import java.util.Map;

import com.querydsl.core.types.Expression;
Expand All @@ -15,6 +14,7 @@

import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.PathKeyedMap;
import com.evolveum.midpoint.repo.sqale.SqaleRepoContext;
import com.evolveum.midpoint.repo.sqale.delta.ItemDeltaValueProcessor;
import com.evolveum.midpoint.repo.sqale.delta.item.UriItemDeltaProcessor;
Expand Down Expand Up @@ -75,8 +75,11 @@ public abstract class SqaleUpdateContext<S, Q extends FlexibleRelationalPathBase
/**
* Map of subcontext for known {@link ItemPath} sub-paths relative to this context.
* {@link ItemName} is not enough to represent multi-value container paths like `assignment/1`.
*
* PathKeyedMap is used to ignore rare, but possible, namespace discrepancies (MID-8258).
* Ignoring namespaces here is acceptable, because it is only used for known built-in containers.
*/
protected final Map<ItemPath, SqaleUpdateContext<?, ?, ?>> subcontexts = new LinkedHashMap<>();
protected final Map<ItemPath, SqaleUpdateContext<?, ?, ?>> subcontexts = new PathKeyedMap<>();

public SqaleUpdateContext(
SqaleRepoContext repositoryContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,7 @@ public void test502AddingAndDeletingMultipleExtensionItems() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);

given("delta adding int extension item");
given("delta mixing add, replace and delete of extension item");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class)
.item(FocusType.F_EXTENSION, new QName("int")).replace(47)
.item(FocusType.F_EXTENSION, new QName("string-mv")).add("s1", "s2", "s3", "s4")
Expand Down Expand Up @@ -3327,6 +3327,39 @@ public void test507SettingExtensionContainerToNull() throws Exception {
assertThat(row.version).isEqualTo(originalRow.version + 1);
assertThat(row.ext).isNull();
}

@Test(description = "MID-8258")
public void test510TwoExtensionItemsDifferentOneMissingNamespace() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);

given("delta replacing extension items with one of the paths missing namespace for the extension container");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class)
.item(new ItemName("extension"), new QName("int")).replace(510)
.item(FocusType.F_EXTENSION, new QName("string")).replace("510")
.asObjectDelta(user1Oid);

when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);

then("operation is successful");
assertThatOperationResult(result).isSuccess();

and("serialized form (fullObject) is updated");
UserType user = repositoryService.getObject(UserType.class, user1Oid, null, result)
.asObjectable();
assertThat(user.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
// no check of ext container, we believe in prism here

and("externalized column is updated and both changes are present");
ExtensionType extensionContainer = user.getExtension();
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
assertThat(row.ext).isNotNull();
assertThat(Jsonb.toMap(row.ext))
.containsEntry(extensionKey(extensionContainer, "int"), 510)
.containsEntry(extensionKey(extensionContainer, "string"), "510");
}
// endregion

// region precondition and modify dynamically
Expand Down

0 comments on commit b772254

Please sign in to comment.