Skip to content

Commit

Permalink
repo-sqale: fixed modify for unmapped/unpersisted multi-paths + test
Browse files Browse the repository at this point in the history
Previously logic like for query was used and unresolvable path
component threw an exception instead of just doing nothing.
  • Loading branch information
virgo47 committed Apr 19, 2021
1 parent dc57339 commit 6be4d21
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Expand Up @@ -75,7 +75,11 @@ private QName resolvePath(ItemPath path) throws QueryException {
ItemName firstName = path.firstName();
path = path.rest();

ItemRelationResolver relationResolver = mapping.relationResolver(firstName);
ItemRelationResolver relationResolver = mapping.getRelationResolver(firstName);
if (relationResolver == null) {
return null; // unmapped, not persisted, nothing to do
}

if (!(relationResolver instanceof SqaleItemRelationResolver)) {
// Again, programmers fault.
throw new IllegalArgumentException("Relation resolver for " + firstName
Expand Down
Expand Up @@ -1676,7 +1676,6 @@ public void test300AddAssignmentStoresItAndGeneratesMissingId()
// TODO: "indexed" containers: .item(ItemPath.create(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION))
// endregion


// TODO test for multi-value (e.g. subtypes) with item delta with both add and delete lists
// But with current implementation this can go to the first hundred section...?

Expand Down Expand Up @@ -1745,5 +1744,34 @@ public void test990ChangeOfNonPersistedAttributeWorksOk()
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
}

@Test
public void test991ChangeInsideNonPersistedContainerWorksOk()
throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);

given("delta with email change for user 1 using property add modification");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class)
.item(UserType.F_BEHAVIOR, BehaviorType.F_AUTHENTICATION,
AuthenticationBehavioralDataType.F_FAILED_LOGINS).replace(5)
.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 userObject = repositoryService.getObject(UserType.class, user1Oid, null, result)
.asObjectable();
assertThat(userObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
assertThat(userObject.getBehavior().getAuthentication().getFailedLogins()).isEqualTo(5);

and("externalized version is updated");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
}
// endregion
}

0 comments on commit 6be4d21

Please sign in to comment.