TransformFeatureSource implements SimpleFeatureSource { @Override public int getCount(Query query) throws IOException { Query txQuery = transformer.transformQuery(query); txQuery.setPropertyNames(Query.ALL_NAMES); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "The original query for count computation{0} has been transformed to {1}", new Object[] { query, txQuery }); } return source.getCount(txQuery); } TransformFeatureSource(SimpleFeatureSource source, Name name, List<Definition> definitions); @Override Name getName(); @Override ResourceInfo getInfo(); @Override DataAccess<SimpleFeatureType, SimpleFeature> getDataStore(); @Override QueryCapabilities getQueryCapabilities(); @Override void addFeatureListener(FeatureListener listener); @Override void removeFeatureListener(FeatureListener listener); @Override SimpleFeatureType getSchema(); @Override ReferencedEnvelope getBounds(); @Override ReferencedEnvelope getBounds(Query query); @Override int getCount(Query query); @Override Set<Key> getSupportedHints(); @Override SimpleFeatureCollection getFeatures(); @Override SimpleFeatureCollection getFeatures(Filter filter); @Override SimpleFeatureCollection getFeatures(Query query);  }
@Test public void testCountWithSelect() throws Exception { SimpleFeatureSource transformed = transformWithSelection(); int actual = transformed.getCount(Query.ALL); int expected = STATES.getCount(Query.ALL); assertEquals(expected, actual); actual = STATES.getCount(new Query("states", CQL.toFilter("state_name = 'Illinois'"))); expected = transformed.getCount(new Query("states_mini", CQL .toFilter("state_name = 'Illinois'"))); assertEquals(expected, actual); }
@Test public void testCountWithRename() throws Exception { SimpleFeatureSource transformed = transformWithSelection(); int actual = transformed.getCount(Query.ALL); int expected = STATES.getCount(Query.ALL); assertEquals(expected, actual); actual = STATES.getCount(new Query("states", CQL.toFilter("state_name = 'Illinois'"))); expected = transformed.getCount(new Query("usa", CQL.toFilter("name = 'Illinois'"))); assertEquals(expected, actual); }
@Test public void testCountWithTransform() throws Exception { SimpleFeatureSource transformed = transformWithSelection(); int actual = transformed.getCount(Query.ALL); int expected = STATES.getCount(Query.ALL); assertEquals(expected, actual); actual = STATES.getCount(new Query("states", CQL.toFilter("state_name = 'Illinois'"))); expected = transformed.getCount(new Query("bstates", CQL.toFilter("name = 'illinois'"))); assertEquals(expected, actual); }