Skip to content

Commit

Permalink
SqaleRepoSearchTest: added test with order by attribute on ref target
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Apr 26, 2022
1 parent 43e0eb5 commit 4093105
Showing 1 changed file with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType;
import com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder;
import com.evolveum.midpoint.repo.sqale.qmodel.object.QObject;
import com.evolveum.midpoint.repo.sqlbase.QueryException;
import com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor;
import com.evolveum.midpoint.schema.SchemaService;
import com.evolveum.midpoint.schema.SearchResultList;
Expand Down Expand Up @@ -296,13 +297,17 @@ public void initObjects() throws Exception {
.assignment(new AssignmentType()
.lifecycleState("ls-user3-ass1")
.metadata(new MetadataType()
.creatorRef(user2Oid, UserType.COMPLEX_TYPE, ORG_DEFAULT)
.createApproverRef(user1Oid, UserType.COMPLEX_TYPE, ORG_DEFAULT))
.activation(new ActivationType()
.validFrom("2021-01-01T00:00:00Z"))
.subtype("ass-subtype-1")
.subtype("ass-subtype-2"))
.linkRef(shadow1Oid, ShadowType.COMPLEX_TYPE)
.assignment(new AssignmentType()
.lifecycleState("ls-user3-ass2")
.metadata(new MetadataType()
.creatorRef(user1Oid, UserType.COMPLEX_TYPE, ORG_DEFAULT))
.activation(new ActivationType()
.validTo("2022-01-01T00:00:00Z")))
.operationExecution(new OperationExecutionType()
Expand Down Expand Up @@ -1893,9 +1898,9 @@ public void test602SearchContainerWithExistsParent() throws SchemaException {
}

@Test
public void test603SearchContainerWithExistsParent() throws SchemaException {
public void test603SearchAccessCertificationCaseContainer() throws SchemaException {
SearchResultList<AccessCertificationCaseType> result = searchContainerTest(
"by owner OID exists", AccessCertificationCaseType.class,
"by stage number", AccessCertificationCaseType.class,
f -> f.item(AccessCertificationCaseType.F_STAGE_NUMBER).gt(1));
assertThat(result)
.extracting(a -> a.getStageNumber())
Expand All @@ -1905,7 +1910,7 @@ public void test603SearchContainerWithExistsParent() throws SchemaException {
@Test
public void test605SearchCaseWorkItemContainer() throws SchemaException {
SearchResultList<CaseWorkItemType> result = searchContainerTest(
"by owner OID exists", CaseWorkItemType.class,
"by stage number", CaseWorkItemType.class,
f -> f.item(CaseWorkItemType.F_STAGE_NUMBER).eq(1));
assertThat(result)
.singleElement()
Expand Down Expand Up @@ -1936,7 +1941,7 @@ public void test610SearchCaseWIContainerByAssigneeName() throws SchemaException
}

@Test
public void test615SearchAssignmentByApproverName() throws SchemaException {
public void test615SearchAssignmentByApproverNameWithOrder() throws SchemaException {
SearchResultList<AssignmentType> result = searchContainerTest(
"by approver name", AssignmentType.class,
f -> f.item(AssignmentType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF,
Expand All @@ -1947,6 +1952,34 @@ public void test615SearchAssignmentByApproverName() throws SchemaException {
.matches(a -> a.getLifecycleState().equals("ls-user3-ass1"));
}

@Test
public void test616OrderByMultiValueReferenceTargetPropertyIsNotPossible() {
assertThatThrownBy(() -> searchContainerTest(
"having any approver (with order)", AssignmentType.class,
f -> f.not().item(AssignmentType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF,
T_OBJECT_REFERENCE, UserType.F_NAME)
.isNull()
.asc(AssignmentType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF,
T_OBJECT_REFERENCE, UserType.F_NAME)))
.isInstanceOf(SystemException.class)
.hasCauseInstanceOf(QueryException.class)
.hasMessageFindingMatch("Item path .* cannot be used for ordering because subquery is used to resolve it");
}

@Test
public void test620OrderBySingleValueReferenceTargetPropertyIsSupported() throws SchemaException {
SearchResultList<AssignmentType> result = searchContainerTest(
"having creator ref name and order by it", AssignmentType.class,
f -> f.not().item(AssignmentType.F_METADATA, MetadataType.F_CREATOR_REF,
T_OBJECT_REFERENCE, UserType.F_NAME)
.isNull()
.asc(AssignmentType.F_METADATA, MetadataType.F_CREATOR_REF,
T_OBJECT_REFERENCE, UserType.F_NAME));
assertThat(result)
.extracting(a -> a.getLifecycleState())
.containsExactly("ls-user3-ass2", "ls-user3-ass1");
}

@Test
public void test690SearchErrorOperationExecutionForTask() throws SchemaException {
SearchResultList<OperationExecutionType> result = searchContainerTest(
Expand Down

0 comments on commit 4093105

Please sign in to comment.