use of org.geotoolkit.ogc.xml.v100.PropertyIsLikeType in project ddf by codice.
the class TestWfsSource method testPropertyIsLikeQuery.
@Test
public void testPropertyIsLikeQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetComparisonOps());
assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
use of org.geotoolkit.ogc.xml.v100.PropertyIsLikeType in project ddf by codice.
the class TestWfsSource method testTwoFeatureTypesQuery.
@Test
public void testTwoFeatureTypesQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
assertTrue(getFeatureType.getQuery().size() == TWO_FEATURES);
Collections.sort(getFeatureType.getQuery(), QUERY_TYPE_COMPARATOR);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetComparisonOps());
assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
QueryType query2 = getFeatureType.getQuery().get(1);
assertTrue(query2.getTypeName().equals(sampleFeatures.get(1)));
assertTrue(query2.getFilter().isSetComparisonOps());
assertTrue(query2.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
use of org.geotoolkit.ogc.xml.v100.PropertyIsLikeType in project ddf by codice.
the class TestWfsSource method testContentTypeQuery.
@Test
public void testContentTypeQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
Filter propertyIsLikeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
Filter contentTypeFilter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
QueryImpl propertyIsLikeQuery = new QueryImpl(builder.allOf(propertyIsLikeFilter, contentTypeFilter));
propertyIsLikeQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs).getFeature(captor.capture());
GetFeatureType getFeatureType = captor.getValue();
assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
QueryType query = getFeatureType.getQuery().get(0);
assertTrue(query.getTypeName().equals(// SAMPLE_FEATURE[0]));
sampleFeatures.get(0)));
assertTrue(query.getFilter().isSetComparisonOps());
assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
use of org.geotoolkit.ogc.xml.v100.PropertyIsLikeType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalCombinatorsOneItem.
private void testLogicalCombinatorsOneItem(String methName) throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> filtersToCombine = new ArrayList<>();
filtersToCombine.add(compFilter1);
Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
// Only one filter was provided to combinator so only that filter is returned as not
// enough filters to combine together
assertNull(filter.getLogicOps());
PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) filter.getComparisonOps().getValue();
String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
assertThat(valRef1, is(mockProperty));
String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
assertThat(literal1, is(LITERAL));
}
use of org.geotoolkit.ogc.xml.v100.PropertyIsLikeType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalNotOfLogicals.
@Test
public void testLogicalNotOfLogicals() throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> subFiltersToBeOred = new ArrayList<>();
subFiltersToBeOred.add(compFilter1);
subFiltersToBeOred.add(compFilter2);
//Perform Test
FilterType filter = delegate.not(delegate.or(subFiltersToBeOred));
//Verify
assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
BinaryLogicOpType logicOrType = (BinaryLogicOpType) logicOpType.getLogicOps().getValue();
assertThat(logicOpType.getLogicOps().getName().toString(), is(LOGICAL_OR_NAME));
PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
assertThat(valRef1, is(mockProperty));
String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
assertThat(literal1, is(LITERAL));
PropertyIsLikeType compOpsType2 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
String valRef2 = fetchPropertyIsLikeExpression(compOpsType2, VALUE_REFERENCE);
assertThat(valRef2, is(mockProperty));
String literal2 = fetchPropertyIsLikeExpression(compOpsType2, LITERAL);
assertThat(literal2, is(LITERAL));
}
Aggregations