Search in sources :

Example 6 with DefaultFilterVisitor

use of org.geotools.filter.visitor.DefaultFilterVisitor in project ddf by codice.

the class FilterBuilderTest method like.

@Test
public void like() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).is().like().text("bar");
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(PropertyIsLike.class), anyObject());
// TODO check case sensitivity
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Test(org.junit.Test)

Example 7 with DefaultFilterVisitor

use of org.geotools.filter.visitor.DefaultFilterVisitor in project ddf by codice.

the class FilterBuilderTest method andOrNull.

@Test
public void andOrNull() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    // FilterBuilder builder = new GeotoolsFilterBuilder();
    //
    //
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.allOf(builder.anyOf(builder.attribute(FOO_ATTRIBUTE).is().empty()));
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(And.class), anyObject());
    inOrder.verify(visitor).visit(isA(Or.class), anyObject());
    ArgumentCaptor<PropertyIsNull> propertyIsNullArgument = ArgumentCaptor.forClass(PropertyIsNull.class);
    verify(visitor).visit(propertyIsNullArgument.capture(), anyObject());
    ExpressionVisitor expVisitor = spy(new DefaultExpressionVisitor() {
    });
    propertyIsNullArgument.getValue().getExpression().accept(expVisitor, null);
    ArgumentCaptor<PropertyName> propertyNameArgument = ArgumentCaptor.forClass(PropertyName.class);
    verify(expVisitor).visit(propertyNameArgument.capture(), anyObject());
    assertEquals(FOO_ATTRIBUTE, propertyNameArgument.getValue().getPropertyName());
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) InOrder(org.mockito.InOrder) Or(org.opengis.filter.Or) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultExpressionVisitor(org.geotools.filter.visitor.DefaultExpressionVisitor) ExpressionVisitor(org.opengis.filter.expression.ExpressionVisitor) PropertyIsNull(org.opengis.filter.PropertyIsNull) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) And(org.opengis.filter.And) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) DefaultExpressionVisitor(org.geotools.filter.visitor.DefaultExpressionVisitor) Test(org.junit.Test)

Example 8 with DefaultFilterVisitor

use of org.geotools.filter.visitor.DefaultFilterVisitor in project ddf by codice.

the class FilterBuilderTest method propertyIsNotEqual.

@Test
public void propertyIsNotEqual() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).notEqualTo().text("bar");
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().notEqualTo().text("bar");
    filter.accept(visitor, null);
    filter = builder.attribute(null).is().notEqualTo().text(null);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(3)).visit(isA(PropertyIsNotEqualTo.class), anyObject());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) PropertyIsNotEqualTo(org.opengis.filter.PropertyIsNotEqualTo) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Test(org.junit.Test)

Example 9 with DefaultFilterVisitor

use of org.geotools.filter.visitor.DefaultFilterVisitor in project ddf by codice.

the class FilterBuilderTest method propertyIsBetween.

@Test
public void propertyIsBetween() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).between().numbers(new Long(5), new Long(7));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().between().numbers(new Long(5), new Long(7));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).between().numbers((short) 5, (short) 7);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).between().numbers(new Integer(5), new Integer(7));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).between().numbers(new Long(5), new Long(7));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).between().numbers(new Float(5), new Float(7));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).between().numbers(new Double(5), new Double(7));
    filter.accept(visitor, null);
    filter = builder.attribute(null).is().between().numbers(null, (Integer) null);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(8)).visit(isA(PropertyIsBetween.class), anyObject());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) Test(org.junit.Test)

Example 10 with DefaultFilterVisitor

use of org.geotools.filter.visitor.DefaultFilterVisitor in project ddf by codice.

the class FilterBuilderTest method after.

@Test
public void after() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).after().date(new Date());
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().after().date(new Date());
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(2)).visit(isA(After.class), anyObject());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) After(org.opengis.filter.temporal.After) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FilterBuilder (ddf.catalog.filter.FilterBuilder)24 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)24 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)24 Test (org.junit.Test)24 Filter (org.opengis.filter.Filter)24 FilterVisitor (org.opengis.filter.FilterVisitor)23 InOrder (org.mockito.InOrder)21 Date (java.util.Date)6 PropertyIsLike (org.opengis.filter.PropertyIsLike)6 PropertyIsNull (org.opengis.filter.PropertyIsNull)4 DWithin (org.opengis.filter.spatial.DWithin)3 DefaultExpressionVisitor (org.geotools.filter.visitor.DefaultExpressionVisitor)2 And (org.opengis.filter.And)2 Or (org.opengis.filter.Or)2 PropertyIsEqualTo (org.opengis.filter.PropertyIsEqualTo)2 ExpressionVisitor (org.opengis.filter.expression.ExpressionVisitor)2 Literal (org.opengis.filter.expression.Literal)2 PropertyName (org.opengis.filter.expression.PropertyName)2 Within (org.opengis.filter.spatial.Within)2 After (org.opengis.filter.temporal.After)2