// @todo need to test no filter, no criteria (return all?)
@Test
public void testSearchTransform() throws Exception {
// prepare command, verify original coordinates first
SearchFeatureRequest request = new SearchFeatureRequest();
request.setLayerId(LAYER_ID);
request.setCrs("EPSG:4326");
request.setMax(3); // this immediately tests whether returning less than the maximum works
SearchCriterion searchCriterion = new SearchCriterion();
searchCriterion.setAttributeName(NAME_ATTRIBUTE);
searchCriterion.setOperator("like");
searchCriterion.setValue("'%3'");
request.setCriteria(new SearchCriterion[] {searchCriterion});
// execute
SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
SearchFeatureRequest.COMMAND, request, null, "en");
// test
Assert.assertFalse(response.isError());
Assert.assertEquals(LAYER_ID, response.getLayerId());
Feature[] features = response.getFeatures();
Assert.assertNotNull(features);
Assert.assertEquals(1, features.length);
Assert.assertEquals("Country 3", features[0].getLabel());
Geometry geometry = features[0].getGeometry();
Assert.assertNotNull(geometry);
Coordinate coor = geometry.getGeometries()[0].getGeometries()[0].getCoordinates()[0];
Assert.assertEquals(-1, coor.getX(), DOUBLE_TOLERANCE);
Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE);
// try again using mercator
request.setCrs("EPSG:900913");
response = (SearchFeatureResponse) dispatcher.execute(SearchFeatureRequest.COMMAND, request, null, "en");
if (response.isError()) {
response.getErrors().get(0).printStackTrace();
}
Assert.assertFalse(response.isError());