use of org.geotools.data.QueryCapabilities in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertPagingFeatureSource.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testInsertPagingFeatureSource() throws Exception {
assertEquals(2, super.getGeogig().getPlatform().availableProcessors());
final List<SimpleFeature> features = ImmutableList.of((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3);
MemoryDataStore store = new MemoryDataStore();
store.addFeatures(features);
final QueryCapabilities caps = mock(QueryCapabilities.class);
when(caps.isOffsetSupported()).thenReturn(true);
FeatureSource source = new ForwardingFeatureSource(store.getFeatureSource(pointsName)) {
@Override
public QueryCapabilities getQueryCapabilities() {
return caps;
}
@Override
public FeatureCollection getFeatures(Query query) throws IOException {
Integer startIndex = query.getStartIndex();
if (startIndex == null) {
return super.getFeatures();
}
int toIndex = (int) Math.min((long) startIndex + query.getMaxFeatures(), features.size());
List<SimpleFeature> result = features.subList(startIndex, toIndex);
return DataUtilities.collection(result);
}
};
assertTrue(source.getQueryCapabilities().isOffsetSupported());
String treePath = "target_typename";
workTree.insert(treePath, source, Query.ALL, LISTENER);
assertEquals(3, workTree.countUnstaged(treePath).featureCount());
}
use of org.geotools.data.QueryCapabilities in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertNonPagingFeatureSource.
@Test
public void testInsertNonPagingFeatureSource() throws Exception {
assertEquals(2, super.getGeogig().getPlatform().availableProcessors());
final List<SimpleFeature> features = ImmutableList.of((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3);
MemoryDataStore store = new MemoryDataStore();
store.addFeatures(features);
final QueryCapabilities caps = mock(QueryCapabilities.class);
when(caps.isOffsetSupported()).thenReturn(true);
@SuppressWarnings("rawtypes") FeatureSource source = store.getFeatureSource(pointsName);
assertFalse(source.getQueryCapabilities().isOffsetSupported());
String treePath = "target_typename";
workTree.insert(treePath, source, Query.ALL, LISTENER);
assertEquals(3, workTree.countUnstaged(treePath).featureCount());
}
Aggregations