use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class WfsSourceTest method testPropertyIsLikeQuery.
@Test
public void testPropertyIsLikeQuery() throws Exception {
mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
assertThat(query.getFilter().isSetComparisonOps(), is(true));
assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class WfsSourceTest method testIntersectQuery.
@Test
public void testIntersectQuery() throws Exception {
mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
setUpMocks(Arrays.asList("Intersects", "BBOX"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
QueryImpl intersectQuery = new QueryImpl(intersectFilter);
intersectQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(intersectQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertMaxFeatures(getFeatureType, intersectQuery);
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
assertThat(query.getFilter().isSetSpatialOps(), is(true));
assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(SpatialOpsType.class)));
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class WfsSourceTest method assertFeature.
private void assertFeature(ExtendedGetFeatureType getFeatureType, boolean sortingEnabled, String sortProperty, String sortOrder) {
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
final QueryType queryType = getFeatureType.getQuery().get(0);
if (sortingEnabled) {
assertThat(queryType.isSetSortBy(), is(true));
assertThat(queryType.getSortBy().getSortProperty().size(), is(1));
assertThat(queryType.getSortBy().getSortProperty().get(0).getPropertyName().getContent().size(), is(1));
assertThat(queryType.getSortBy().getSortProperty().get(0).getPropertyName().getContent().get(0), is(sortProperty));
assertThat(queryType.getSortBy().getSortProperty().get(0).getSortOrder().value(), is(sortOrder));
} else {
assertThat(queryType.isSetSortBy(), is(false));
}
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class WfsSourceTest method testAndQuery.
@Test
public void testAndQuery() throws Exception {
mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
Filter propertyIsLikeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
Filter contentTypeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(sampleFeatures.get(0).getLocalPart());
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.allOf(propertyIsLikeFilter, contentTypeFilter));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
assertThat(query.getFilter().isSetLogicOps(), is(true));
assertThat(query.getFilter().getLogicOps().getValue(), is(instanceOf(BinaryLogicOpType.class)));
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class WfsSourceTest method testQuerySendsHitsRequestBeforeResultsRequest.
@Test
public void testQuerySendsHitsRequestBeforeResultsRequest() throws Exception {
mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
final QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
final ExtendedGetFeatureType getHits = captor.getAllValues().get(0);
assertThat(getHits.getResultType(), is(ResultTypeType.HITS));
assertThat(getHits.getMaxFeatures(), is(nullValue()));
final ExtendedGetFeatureType getResults = captor.getAllValues().get(1);
assertThat(getResults.getResultType(), is(ResultTypeType.RESULTS));
assertMaxFeatures(getResults, propertyIsLikeQuery);
for (final ExtendedGetFeatureType getFeatureType : captor.getAllValues()) {
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
final QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
assertThat(query.getFilter().isSetComparisonOps(), is(true));
assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
}
}
Aggregations