Search in sources :

Example 16 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractLdapConnTest method test162SeachFirst50AccountsOffset0.

@Test
public void test162SeachFirst50AccountsOffset0() throws Exception {
    final String TEST_NAME = "test152SeachFirst50Accounts";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createEmptyPaging();
    paging.setOffset(0);
    paging.setMaxSize(50);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 50, task, result);
    assertConnectorOperationIncrement(1, 51);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = searchResultList.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1, 2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 17 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractLdapConnTest method singleInfernoSearch.

private void singleInfernoSearch(ObjectQuery query, int expectedNumberOfResults, Integer offset, Integer maxSize, String sortAttrName, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    ObjectPaging paging = ObjectPaging.createPaging(offset, maxSize);
    paging.setOrdering(getAttributePath(resource, sortAttrName), OrderDirection.ASCENDING);
    query.setPaging(paging);
    final MutableInt count = new MutableInt();
    ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {

        @Override
        public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
            count.increment();
            return true;
        }
    };
    modelService.searchObjectsIterative(ShadowType.class, query, handler, null, task, result);
    assertEquals("Unexpected number of search results", expectedNumberOfResults, count.intValue());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) MutableInt(org.apache.commons.lang.mutable.MutableInt) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler)

Example 18 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractAdLdapTest method test182Search2AccountsOffset1SortCn.

/**
	 * Blocksize is 5, so this is in one block.
	 * There is offset, so VLV should be used.
	 * Explicit sorting.
	 */
@Test
public void test182Search2AccountsOffset1SortCn() throws Exception {
    final String TEST_NAME = "test182Search2AccountsOffset1SortCn";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(1, 2);
    paging.setOrdering(getAttributePath(resource, "cn"), OrderDirection.ASCENDING);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> shadows = doSearch(TEST_NAME, query, 2, task, result);
    assertAccountShadow(shadows.get(0), "CN=a5vg a5vg,CN=Users,DC=win,DC=evolveum,DC=com");
    assertAccountShadow(shadows.get(1), "CN=Adalbert Meduza,OU=evolveum,DC=win,DC=evolveum,DC=com");
    //        assertAccountShadow(shadows.get(0), "CN=Adalbert Meduza,OU=evolveum,DC=win,DC=evolveum,DC=com");
    //        assertAccountShadow(shadows.get(1), "CN=Adalbert Meduza1,OU=evolveum,DC=win,DC=evolveum,DC=com");
    assertConnectorOperationIncrement(1);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Example 19 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractLdapConnTest method test154SeachFirst222Accounts.

/**
	 * Blocksize is 100, so this gets more than two blocks.
	 */
@Test
public void test154SeachFirst222Accounts() throws Exception {
    final String TEST_NAME = "test154SeachFirst222Accounts";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createEmptyPaging();
    paging.setMaxSize(222);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 222, task, result);
    assertConnectorOperationIncrement(1, 223);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = searchResultList.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1, 2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 20 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractLdapConnTest method test182Search50AccountsOffset20SortUid.

/**
	 * Blocksize is 100, so this is in one block.
	 * There is offset, so VLV should be used.
	 * Explicit sorting.
	 */
@Test
public void test182Search50AccountsOffset20SortUid() throws Exception {
    final String TEST_NAME = "test182Search50AccountsOffset20SortUid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(20, 50);
    paging.setOrdering(getAttributePath(resource, "uid"), OrderDirection.ASCENDING);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> shadows = doSearch(TEST_NAME, query, 50, task, result);
    assertAccountShadow(shadows.get(0), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_19_UID : ACCOUNT_20_UID));
    assertAccountShadow(shadows.get(49), toAccountDn(isIdmAdminInteOrgPerson() ? ACCOUNT_68_UID : ACCOUNT_69_UID));
    assertConnectorOperationIncrement(1, 51);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = shadows.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1, 2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)40 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)32 PrismObject (com.evolveum.midpoint.prism.PrismObject)28 Task (com.evolveum.midpoint.task.api.Task)28 Test (org.testng.annotations.Test)25 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)17 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)6 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)6 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)6 QName (javax.xml.namespace.QName)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)3 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2