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 Aug 22, 2022
2 parents 2302dab + 6cc4ed7 commit 0581d69
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,16 @@ public void initObjects() throws Exception {

// users
creatorOid = repositoryService.addObject(
new UserType().name("creator").asPrismObject(),
new UserType().name("creator").familyName("Creator").asPrismObject(),
null, result);
modifierOid = repositoryService.addObject(
new UserType().name("modifier").asPrismObject(),
new UserType().name("modifier").givenName("Modifier").asPrismObject(),
null, result);

UserType user1 = new UserType().name("user-1")
.fullName("User Name 1")
.givenName("First")
.familyName("Adams")
.metadata(new MetadataType()
.creatorRef(creatorOid, UserType.COMPLEX_TYPE, relation1)
.createChannel("create-channel")
Expand Down Expand Up @@ -273,6 +275,7 @@ public void initObjects() throws Exception {
user1Oid = repositoryService.addObject(user1.asPrismObject(), null, result);

UserType user2 = new UserType().name("user-2")
.familyName("Adams")
.parentOrgRef(orgXOid, OrgType.COMPLEX_TYPE)
.parentOrgRef(org11Oid, OrgType.COMPLEX_TYPE, relation1)
.subtype("workerA")
Expand Down Expand Up @@ -312,6 +315,8 @@ public void initObjects() throws Exception {
user2Oid = repositoryService.addObject(user2.asPrismObject(), null, result);

UserType user3 = new UserType().name("user-3")
.givenName("Third")
.familyName("Adams")
.costCenter("50")
.parentOrgRef(orgXOid, OrgType.COMPLEX_TYPE, relation2)
.parentOrgRef(org21Oid, OrgType.COMPLEX_TYPE, relation1)
Expand Down Expand Up @@ -2824,5 +2829,23 @@ public void test996InvalidFuzzyStringSearchWithMultipleValues() {
.isInstanceOf(SystemException.class) // the exception may change
.hasMessageMatching("Filter 'levenshtein: employeeNumber, .*' should contain at most one value, but it has 2 of them\\.");
}

@Test
public void test999MultipleOrdersAreSupportedByFluentApiAndRepository() throws SchemaException {
given("search users query ordered by family and given name");
ObjectQuery query = prismContext.queryFor(UserType.class)
.asc(UserType.F_FAMILY_NAME).desc(UserType.F_GIVEN_NAME)
.build();

when("the query is executed");
OperationResult opResult = createOperationResult();
SearchResultList<UserType> result = searchObjects(UserType.class, query, opResult);

then("sorted users are returned (NULLs last for ASC, first for DESC)");
assertThatOperationResult(opResult).isSuccess();
assertThat(result)
.extracting(o -> o.getOid())
.containsExactly(user2Oid, user3Oid, user1Oid, creatorOid, modifierOid, user4Oid);
}
// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -1761,4 +1761,22 @@ public void test980SearchPasswordCreateTimestamp() throws Exception {
assertEquals("Should find one user", 1, users.size());
assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig());
}

@Test
public void test999MultipleOrdersAreSupportedByFluentApiAndRepository() throws SchemaException {
given("search users query ordered by family and given name");
ObjectQuery query = prismContext.queryFor(UserType.class)
.asc(UserType.F_GIVEN_NAME).desc(UserType.F_FAMILY_NAME)
.build();

when("the query is executed");
OperationResult opResult = createOperationResult();
List<PrismObject<UserType>> result = repositoryService.searchObjects(UserType.class, query, null, opResult);

then("sorted users are returned");
assertThatOperationResult(opResult).isSuccess();
assertThat(result)
.extracting(o -> PolyString.getOrig(o.asObjectable().getFamilyName()))
.containsExactly(null, "Marley", "UserX00003", "UserX00002");
}
}

0 comments on commit 0581d69

Please sign in to comment.