Search in sources :

Example 16 with SearchResultList

use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.

the class SqaleRepoSearchTest method test960SearchGetNames.

@Test
public void test960SearchGetNames() throws SchemaException {
    var options = SchemaService.get().getOperationOptionsBuilder().resolveNames().build();
    ObjectQuery query = PrismContext.get().queryFor(FocusType.class).all().build();
    SearchResultList<FocusType> result = searchObjects(FocusType.class, query, createOperationResult(), options.iterator().next());
    assertNotNull(result);
    // noinspection rawtypes
    Visitor check = visitable -> {
        if (visitable instanceof PrismReferenceValue) {
            assertNotNull(((PrismReferenceValue) visitable).getTargetName(), "TargetName should be set.");
        }
    };
    for (FocusType obj : result) {
        // noinspection unchecked
        obj.asPrismObject().accept(check);
    }
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 17 with SearchResultList

use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.

the class SqaleRepoSearchTest method test503SearchObjectWithAnyValueForExtensionItemOrderedByIt.

@Test
public void test503SearchObjectWithAnyValueForExtensionItemOrderedByIt() throws SchemaException {
    SearchResultList<UserType> result = searchUsersTest("with extension string item with any value ordered by that item", f -> f.not().item(UserType.F_EXTENSION, new QName("string")).isNull().asc(UserType.F_EXTENSION, new QName("string")), user1Oid, user2Oid);
    // "other..." < "string..."
    assertThat(result.get(0).getOid()).isEqualTo(user2Oid);
    result = searchUsersTest("with extension string item with any value ordered by that item", f -> f.not().item(UserType.F_EXTENSION, new QName("string")).isNull().desc(UserType.F_EXTENSION, new QName("string")), user1Oid, user2Oid);
    // to be sure it works both ways
    assertThat(result.get(0).getOid()).isEqualTo(user1Oid);
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QName(javax.xml.namespace.QName) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 18 with SearchResultList

use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.

the class SqaleRepoSearchTest method test960SearchByAxiomQueryLanguage.

@Test
public void test960SearchByAxiomQueryLanguage() throws SchemaException {
    OperationResult operationResult = createOperationResult();
    given("query for not-indexed extension");
    SearchResultList<FocusType> result = searchObjects(FocusType.class, ". type UserType and costCenter startsWith \"5\"", operationResult);
    expect("searchObjects throws exception because of not-indexed item");
    assertThat(result).extracting(f -> f.getOid()).containsExactlyInAnyOrder(user3Oid, user4Oid);
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 19 with SearchResultList

use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.

the class SqaleRepoSearchTest method test911SearchByOidLowerThan.

// Following OID tests use services in one cost center, only OID conditions are of interest.
@Test
public void test911SearchByOidLowerThan() throws SchemaException {
    when("searching for objects with OID lower than");
    OperationResult operationResult = createOperationResult();
    SearchResultList<ServiceType> result = repositorySearchObjects(ServiceType.class, prismContext.queryFor(ServiceType.class).item(ServiceType.F_COST_CENTER).eq("OIDTEST").and().item(PrismConstants.T_ID).lt("00000000-1000-0000-0000-000000000000").build(), operationResult);
    then("user with OID lower than specified are returned");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(result).extracting(o -> o.getOid()).containsExactlyInAnyOrder();
}
Also used : QFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.QFocus) XmlTypeConverter.createXMLGregorianCalendar(com.evolveum.midpoint.prism.xml.XmlTypeConverter.createXMLGregorianCalendar) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) T_PARENT(com.evolveum.midpoint.prism.PrismConstants.T_PARENT) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) F_VALID_FROM(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_FROM) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Assert(org.testng.Assert) F_ACTIVATION(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType.F_ACTIVATION) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Assertions(org.assertj.core.api.Assertions) BigInteger(java.math.BigInteger) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QAssignmentHolder(com.evolveum.midpoint.repo.sqale.qmodel.object.QAssignmentHolder) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) BeforeClass(org.testng.annotations.BeforeClass) ORG_DEFAULT(com.evolveum.midpoint.schema.constants.SchemaConstants.ORG_DEFAULT) MiscUtil(com.evolveum.midpoint.util.MiscUtil) UUID(java.util.UUID) F_VALID_TO(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType.F_VALID_TO) Instant(java.time.Instant) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MiscUtil.asXMLGregorianCalendar(com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar) PolyStringItemFilterProcessor(com.evolveum.midpoint.repo.sqlbase.filtering.item.PolyStringItemFilterProcessor) List(java.util.List) ItemName(com.evolveum.midpoint.prism.path.ItemName) SchemaService(com.evolveum.midpoint.schema.SchemaService) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) F_ASSIGNMENT(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType.F_ASSIGNMENT) SystemException(com.evolveum.midpoint.util.exception.SystemException) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) T_OBJECT_REFERENCE(com.evolveum.midpoint.prism.PrismConstants.T_OBJECT_REFERENCE) QName(javax.xml.namespace.QName) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 20 with SearchResultList

use of com.evolveum.midpoint.schema.SearchResultList in project midpoint by Evolveum.

the class AuditSearchTest method test252SearchByChangedItemsComplexPath.

@Test
public void test252SearchByChangedItemsComplexPath() throws SchemaException {
    when("searching audit by changed items equal to complex path");
    SearchResultList<AuditEventRecordType> result = searchObjects(prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_CHANGED_ITEM).eq(new ItemPathType(ItemPath.create(ObjectType.F_METADATA, MetadataType.F_REQUEST_TIMESTAMP))).build());
    then("only audit events with the specified changed items are returned");
    assertThat(result).hasSize(1);
    assertThat(result).extracting(aer -> aer.getParameter()).containsExactlyInAnyOrder("1");
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) Arrays(java.util.Arrays) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) com.evolveum.midpoint.xml.ns._public.common.audit_3(com.evolveum.midpoint.xml.ns._public.common.audit_3) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) PrismObject(com.evolveum.midpoint.prism.PrismObject) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) CHANNEL_REST_URI(com.evolveum.midpoint.schema.constants.SchemaConstants.CHANNEL_REST_URI) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) List(java.util.List) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ContextConfiguration(org.springframework.test.context.ContextConfiguration) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) Comparator(java.util.Comparator) NotNull(org.jetbrains.annotations.NotNull) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) Test(org.testng.annotations.Test)

Aggregations

SearchResultList (com.evolveum.midpoint.schema.SearchResultList)45 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)38 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)33 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)31 Test (org.testng.annotations.Test)28 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)27 List (java.util.List)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)26 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)25 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)23 MiscUtil (com.evolveum.midpoint.util.MiscUtil)23 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)17 TestUtil (com.evolveum.midpoint.test.util.TestUtil)17 UUID (java.util.UUID)17 BeforeClass (org.testng.annotations.BeforeClass)17 com.evolveum.midpoint.prism (com.evolveum.midpoint.prism)14 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)14 SystemException (com.evolveum.midpoint.util.exception.SystemException)10