Search in sources :

Example 16 with FilterBuilder

use of ddf.catalog.filter.FilterBuilder in project ddf by codice.

the class FilterBuilderTest method notNull.

@Test
public void notNull() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.not(builder.attribute(FOO_ATTRIBUTE).is().empty());
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(Not.class), any());
    inOrder.verify(visitor).visit(isA(PropertyIsNull.class), any());
}
Also used : Not(org.opengis.filter.Not) InOrder(org.mockito.InOrder) PropertyIsNull(org.opengis.filter.PropertyIsNull) 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 17 with FilterBuilder

use of ddf.catalog.filter.FilterBuilder in project ddf by codice.

the class FilterBuilderTest method propertyIsEqual.

@Test
public void propertyIsEqual() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).equalTo().text("bar");
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().equalTo().text("bar");
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().text("bar");
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().bool(true);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().bytes(new byte[] {});
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().date(new Date());
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().number((short) 5);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().number(new Integer(5));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().number(new Long(5));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().number(new Float(5));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().number(new Double(5));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().wkt("POINT (10, 30)");
    filter.accept(visitor, null);
    filter = builder.attribute(null).is().text(null);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).equalTo().dateRange(new Date(1), new Date(2));
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(13)).visit(isA(PropertyIsEqualTo.class), any());
    inOrder.verify(visitor, times(1)).visit(isA(During.class), any());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) Date(java.util.Date) During(org.opengis.filter.temporal.During) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) 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 18 with FilterBuilder

use of ddf.catalog.filter.FilterBuilder in project ddf by codice.

the class FilterBuilderTest method operatorWithinBufferNull.

@Test(expected = IllegalArgumentException.class)
public void operatorWithinBufferNull() {
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute("something").withinBuffer().wkt(null);
}
Also used : 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 19 with FilterBuilder

use of ddf.catalog.filter.FilterBuilder 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), any());
}
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 20 with FilterBuilder

use of ddf.catalog.filter.FilterBuilder in project ddf by codice.

the class FilterBuilderTest method operatorBeyondNull.

@Test(expected = IllegalArgumentException.class)
public void operatorBeyondNull() {
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute("something").beyond().wkt(null);
}
Also used : 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)

Aggregations

FilterBuilder (ddf.catalog.filter.FilterBuilder)54 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)49 Test (org.junit.Test)44 Filter (org.opengis.filter.Filter)41 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)24 FilterVisitor (org.opengis.filter.FilterVisitor)23 InOrder (org.mockito.InOrder)21 CatalogFramework (ddf.catalog.CatalogFramework)11 ArrayList (java.util.ArrayList)10 Date (java.util.Date)10 QueryResponse (ddf.catalog.operation.QueryResponse)9 FilterAdapter (ddf.catalog.filter.FilterAdapter)7 UriInfo (javax.ws.rs.core.UriInfo)7 Metacard (ddf.catalog.data.Metacard)6 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)6 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)6 TikaMimeTypeResolver (ddf.mime.tika.TikaMimeTypeResolver)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InputStream (java.io.InputStream)6 PropertyIsLike (org.opengis.filter.PropertyIsLike)6