Search in sources :

Example 51 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestWfsSource method testPagingStartIndexOne.

/**
     * Given 10 features (and metacards) exist that match search criteria, since page size=4 and
     * startIndex=1, should get 4 results back - metacards 1 thru 4.
     *
     * @throws WfsException
     * @throws SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingStartIndexOne() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = 4;
    int startIndex = 1;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, MAX_FEATURES, null);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(pageSize));
    assertThat(response.getHits(), equalTo(new Long(MAX_FEATURES)));
    // Verify that metacards 1 thru 4 were returned since pageSize=4
    assertCorrectMetacardsReturned(results, startIndex, pageSize);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 52 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestWfsSource method testPagingPageSizeExceedsFeatureCountStartIndexOne.

/**
     * Given 10 features (and metacards) exist that match search criteria, since page size=20 (which
     * is larger than number of features) and startIndex=1, should get 10 results back - metacards 1
     * thru 10.
     *
     * @throws WfsException,                     SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingPageSizeExceedsFeatureCountStartIndexOne() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = 20;
    int startIndex = 1;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, MAX_FEATURES, null);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(MAX_FEATURES));
    assertThat(response.getHits(), equalTo(new Long(MAX_FEATURES)));
    // Verify that metacards 1 thru 10 were returned
    assertCorrectMetacardsReturned(results, startIndex, MAX_FEATURES);
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 53 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestWfsSource method testPagingPageSizeNegative.

/**
     * Verify that if page size is negative, WfsSource defaults it to the max features that can be
     * returned.
     *
     * @throws WfsException,                     SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingPageSizeNegative() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = -1;
    int startIndex = 1;
    int numResults = WfsSource.WFS_MAX_FEATURES_RETURNED + 10;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, 1, numResults);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(WfsSource.WFS_MAX_FEATURES_RETURNED));
    assertThat(response.getHits(), equalTo(new Long(numResults)));
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 54 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestWfsSource method testPagingPageSizeExceedsMaxFeaturesThatCanBeReturned.

/**
     * Given 1010 features (and metacards) exist that match search criteria, since page size=1001
     * (which is larger than max number of features the WfsSource allows to be returned) and
     * startIndex=1, should get 1000 results back, but a total hits of 1010.
     *
     * @throws WfsException,                     SecurityServiceException
     * @throws TransformerConfigurationException
     * @throws UnsupportedQueryException
     */
@Test
public void testPagingPageSizeExceedsMaxFeaturesThatCanBeReturned() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
    int pageSize = WfsSource.WFS_MAX_FEATURES_RETURNED + 1;
    int startIndex = 1;
    int numResults = WfsSource.WFS_MAX_FEATURES_RETURNED + 10;
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, 1, numResults);
    SourceResponse response = executeQuery(startIndex, pageSize);
    List<Result> results = response.getResults();
    assertThat(results.size(), is(WfsSource.WFS_MAX_FEATURES_RETURNED));
    assertThat(response.getHits(), equalTo(new Long(numResults)));
}
Also used : SourceResponse(ddf.catalog.operation.SourceResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 55 with SourceResponse

use of ddf.catalog.operation.SourceResponse in project ddf by codice.

the class TestWfsSource method executeQuery.

private SourceResponse executeQuery(int startIndex, int pageSize) throws UnsupportedQueryException {
    Filter filter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
    Query query = new QueryImpl(filter, startIndex, pageSize, null, false, 0);
    QueryRequest request = new QueryRequestImpl(query);
    SourceResponse response = source.query(request);
    return response;
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl)

Aggregations

SourceResponse (ddf.catalog.operation.SourceResponse)199 Test (org.junit.Test)146 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)99 QueryImpl (ddf.catalog.operation.impl.QueryImpl)95 Result (ddf.catalog.data.Result)79 Metacard (ddf.catalog.data.Metacard)73 Filter (org.opengis.filter.Filter)58 QueryRequest (ddf.catalog.operation.QueryRequest)52 BinaryContent (ddf.catalog.data.BinaryContent)40 ResultImpl (ddf.catalog.data.impl.ResultImpl)29 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)25 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)24 Matchers.containsString (org.hamcrest.Matchers.containsString)24 Matchers.anyString (org.mockito.Matchers.anyString)21 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 Serializable (java.io.Serializable)20 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)19 SortByImpl (ddf.catalog.filter.impl.SortByImpl)18 Map (java.util.Map)16