use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class FilterAdapterTest method testTemporalRelativeFilter.
@Test
public void testTemporalRelativeFilter() {
PropertyIsEqualTo mockTemporalFilter = mock(PropertyIsEqualTo.class);
PropertyName mockPropertyName = mock(PropertyName.class);
doReturn("created").when(mockPropertyName).accept(any(), any());
Literal mockLiteral = mock(Literal.class);
doReturn("RELATIVE(P2Y3M2DT1H6M)").when(mockLiteral).accept(any(), any());
doReturn(mockPropertyName).when(mockTemporalFilter).getExpression1();
doReturn(mockLiteral).when(mockTemporalFilter).getExpression2();
// Use fake delegate to return fake result to verify operation
// This will only return the expected result if the relative temporal path is followed
FilterDelegate mockFilterDelegate = mock(FilterDelegate.class);
doReturn(Boolean.TRUE).when(mockFilterDelegate).propertyIsBetween(any(), any(Date.class), any(Date.class));
try {
GeotoolsFilterAdapterImpl geotoolsFilterAdapter = new GeotoolsFilterAdapterImpl();
assertThat(geotoolsFilterAdapter.visit(mockTemporalFilter, mockFilterDelegate), is(true));
} catch (Exception e) {
fail("The filter was not handled as a between query after generating literal dates.");
}
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class OpenSearchFilterVisitorTest method testPropertyEqualToNotNest.
@Test
public void testPropertyEqualToNotNest() {
PropertyIsEqualTo propertyIsEqualToFilter = (PropertyIsEqualTo) geotoolsFilterBuilder.attribute(ID_ATTRIBUTE_NAME).is().equalTo().text(TEST_STRING);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
openSearchFilterVisitorObject.setCurrentNest(NestedTypes.NOT);
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(propertyIsEqualToFilter, openSearchFilterVisitorObject);
assertThat(result.getId(), is(nullValue()));
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testSourceIdFilter.
@Test
public void testSourceIdFilter() {
Expression val = factory.literal("source1");
Expression val2 = factory.literal("source2");
Expression sourceExpr = factory.property(Core.SOURCE_ID);
PropertyIsEqualTo filter = factory.equal(sourceExpr, val, false);
Filter filter2 = factory.equal(sourceExpr, val2, false);
Filter likeFilter = factory.like(attrExpr, "something");
Filter sourceFilter = factory.or(filter, filter2);
Filter totalFilter = factory.and(sourceFilter, likeFilter);
Object obj = totalFilter.accept(visitor, null);
assertThat(obj, instanceOf(PropertyIsLike.class));
PropertyIsLike duplicate = (PropertyIsLike) obj;
assertThat(duplicate.getExpression(), is(attrExpr));
assertThat(duplicate.getLiteral(), is("something"));
assertThat(visitor.getSourceIds().size(), is(2));
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsEqualToCaseInsensitive.
@Test
public void testVisitPropertyIsEqualToCaseInsensitive() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equal(attrExpr, val, false);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(false));
}
use of org.opengis.filter.PropertyIsEqualTo in project polymap4-core by Polymap4.
the class ColorMap2FilterEditor method initValues.
protected void initValues() {
List<Mapped<Filter, Color>> values = prop.get().values();
for (Mapped<Filter, Color> entry : values) {
PropertyIsEqualTo filter = (PropertyIsEqualTo) entry.key();
propertyName = ((PropertyName) filter.getExpression1()).getPropertyName();
Object value = ((Literal) filter.getExpression2()).getValue();
colorMap.add(new Triple(value, -1, entry.value()));
}
}
Aggregations