From d4c952b53d411cd7590d8b3a1017e4428c4c8b85 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Fri, 10 Sep 2021 11:10:09 +0200 Subject: [PATCH] SqaleRepoSearchTest: added test demonstrating full-blown validity scan --- .../repo/sqale/func/SqaleRepoSearchTest.java | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java index 02392542d4d..86a4cdab723 100644 --- a/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java +++ b/repo/repo-sqale/src/test/java/com/evolveum/midpoint/repo/sqale/func/SqaleRepoSearchTest.java @@ -15,6 +15,10 @@ import static com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar; import static com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT; import static com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT; +import static com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION; import java.math.BigDecimal; import java.math.BigInteger; @@ -22,6 +26,7 @@ import java.util.List; import java.util.UUID; import java.util.function.Function; +import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; import org.jetbrains.annotations.NotNull; @@ -897,25 +902,42 @@ public void test322AndFilterVersusExistsAndFilter() throws SchemaException { @Test public void test323ActivationOrAssignmentActivationBeforeDate() throws SchemaException { - // this is close to real-life validity query + XMLGregorianCalendar scanDate = createXMLGregorianCalendar("2022-01-01T00:00:00Z"); searchUsersTest("having activation/valid* or assignment/activation/valid* before", - f -> f.item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM) - .le(createXMLGregorianCalendar("2022-01-01T00:00:00Z")) + f -> f.item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM).le(scanDate) .or() - .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO) - .le(createXMLGregorianCalendar("2022-01-01T00:00:00Z")) + .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO).le(scanDate) .or() .exists(UserType.F_ASSIGNMENT) .block() // block necessary, otherwise the second item goes from User - .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM) - .le(createXMLGregorianCalendar("2022-01-01T00:00:00Z")) + .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM).le(scanDate) .or() - .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO) - .le(createXMLGregorianCalendar("2022-01-01T00:00:00Z")) + .item(AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO).le(scanDate) .endBlock(), user1Oid, user2Oid, user3Oid); } + @Test + public void test324ActivationOrAssignmentActivationBetweenDates() throws SchemaException { + // taken from FocusValidityScanPartialExecutionSpecifics.createStandardFilter + XMLGregorianCalendar lastScanTimestamp = createXMLGregorianCalendar("2021-01-01T00:00:00Z"); + XMLGregorianCalendar thisScanTimestamp = createXMLGregorianCalendar("2021-06-01T00:00:00Z"); + searchUsersTest("having activation/valid* or assignment/activation/valid* between dates", + f -> f.item(F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp) + .and().item(F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp) + .or().item(F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp) + .and().item(F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp) + .or().exists(F_ASSIGNMENT) + .block() + .item(AssignmentType.F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp) + .and().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp) + .or().item(AssignmentType.F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp) + .and().item(AssignmentType.F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp) + .endBlock(), + user1Oid, user2Oid); + // user3 barely misses it, it has validFrom = lastSCanTimestamp, but the condition > is exclusive + } + @Test public void test325ExistsFilterWithSizeColumn() throws SchemaException { searchObjectTest("having pending operations", ShadowType.class,