use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testGmlImport.
@Test
public void testGmlImport() throws Exception {
mapSchemaToFeatures(GML_IMPORT_SCHEMA, ONE_FEATURE);
setUpMocks(Collections.singletonList("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.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testQueryTwoFeaturesWithMixedPropertyNames.
@Test
public void testQueryTwoFeaturesWithMixedPropertyNames() throws Exception {
mapSchemaToSingleFeature(ONE_TEXT_PROPERTY_SCHEMA_PERSON, 0);
mapSchemaToSingleFeature(ONE_TEXT_PROPERTY_SCHEMA_DOG, 1);
setUpMocks(null, null, TWO_FEATURES, TWO_FEATURES);
Filter orderPersonFilter = builder.attribute(ORDER_PERSON).is().like().text(LITERAL);
Filter mctFeature1Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
Filter feature1Filter = builder.allOf(Arrays.asList(orderPersonFilter, mctFeature1Filter));
Filter orderDogFilter = builder.attribute(ORDER_DOG).is().like().text(LITERAL);
Filter mctFeature2Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
Filter feature2Filter = builder.allOf(Arrays.asList(orderDogFilter, mctFeature2Filter));
Filter totalFilter = builder.anyOf(Arrays.asList(feature1Filter, feature2Filter));
QueryImpl inQuery = new QueryImpl(totalFilter);
inQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(inQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertMaxFeatures(getFeatureType, inQuery);
getFeatureType.getQuery().sort(QUERY_TYPE_COMPARATOR);
assertThat(TWO_FEATURES, is(getFeatureType.getQuery().size()));
// Feature 1
QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getTypeName().get(0), equalTo(sampleFeatures.get(0)));
// this should only have 1 filter which is a comparison
assertThat(query.getFilter().isSetComparisonOps(), is(true));
assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
assertThat(pilt, notNullValue());
assertThat(ORDER_PERSON, is(pilt.getPropertyName().getContent().get(0)));
// Feature 2
QueryType query2 = getFeatureType.getQuery().get(1);
assertThat(query2.getTypeName().get(0), is(sampleFeatures.get(1)));
// this should only have 1 filter which is a comparison
assertThat(query2.getFilter().isSetComparisonOps(), is(true));
assertThat(query2.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
PropertyIsLikeType pilt2 = (PropertyIsLikeType) query2.getFilter().getComparisonOps().getValue();
assertThat(ORDER_DOG, is(pilt2.getPropertyName().getContent().get(0)));
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testTwoIntersectQuery.
@Test
public void testTwoIntersectQuery() throws Exception {
mapSchemaToFeatures(TWO_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)));
// The Text Properties should be ORed
assertThat(query.getFilter(), notNullValue());
assertThat(query.getFilter().isSetLogicOps(), is(true));
assertThat(query.getFilter().getLogicOps().getValue(), is(instanceOf(LogicOpsType.class)));
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testBboxQuery.
@Test
public void testBboxQuery() throws Exception {
mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
setUpMocks(Collections.singletonList("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.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testTypeNameHasNoPrefix.
@Test
public void testTypeNameHasNoPrefix() throws Exception {
// Setup
final String TITLE = "title";
final String searchPhrase = "*";
final int pageSize = 1;
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), 3, false, false, 3);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
query.setPageSize(pageSize);
SortBy sortBy = new SortByImpl(TITLE, SortOrder.DESCENDING);
query.setSortBy(sortBy);
// Perform test
GetFeatureType featureType = source.buildGetFeatureRequest(query);
// Validate
List<JAXBElement<?>> queryList = featureType.getAbstractQueryExpression();
for (JAXBElement<?> queryType : queryList) {
Object val = queryType.getValue();
QueryType queryTypeVal = (QueryType) val;
assertThat(queryTypeVal.getTypeNames().get(0), containsString("SampleFeature"));
assertThat(queryTypeVal.getTypeNames().get(0), is(not(containsString("Prefix"))));
assertThat(queryTypeVal.getTypeNames().get(0), is(not(containsString(":"))));
}
}
Aggregations