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)));
}
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)));
}
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;
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class TestWfsSource method testPaging.
// Simulates query by ID (which is analogous to clicking on link in search
// results to
// view associated metacard in XML)
@Test
public void testPaging() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
int pageSize = 4;
int startIndex = 1;
int numFeatures = 1;
setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, numFeatures, null);
SourceResponse response = executeQuery(startIndex, pageSize);
List<Result> results = response.getResults();
assertThat(results.size(), is(1));
assertThat(response.getHits(), equalTo(new Long(numFeatures)));
}
use of ddf.catalog.operation.SourceResponse in project ddf by codice.
the class SolrProviderTest method testQueryHasLuceneSpecialCharacters.
@Test
public void testQueryHasLuceneSpecialCharacters() throws Exception {
deleteAllIn(provider);
List<Metacard> list = Arrays.asList((Metacard) new MockMetacard(Library.getFlagstaffRecord()), new MockMetacard(Library.getTampaRecord()));
create(list);
// if + is escaped, this query will be an implicit OR otherwise both both terms would be
// required
Filter txtFilter = filterBuilder.attribute(Metacard.ANY_TEXT).like().text("+Flag?taff +" + TAMPA_QUERY_PHRASE);
SourceResponse response = provider.query(new QueryRequestImpl(new QueryImpl(txtFilter)));
assertEquals(1, response.getResults().size());
}
Aggregations