Search in sources :

Example 41 with FilterBuilder

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

the class FilterBuilderTest method operatorBeforeNull.

@Test(expected = IllegalArgumentException.class)
public void operatorBeforeNull() {
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute("something").before().date(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 42 with FilterBuilder

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

the class FilterBuilderTest method likeCaseSensitive.

@Test
public void likeCaseSensitive() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).is().like().caseSensitiveText("bAr");
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(PropertyIsLike.class), any());
// 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 43 with FilterBuilder

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

the class FilterBuilderTest method during.

@Test
public void during() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).during().dates(new Date(), new Date(System.currentTimeMillis() + 10000000));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).during().next(1000);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).during().last(1000);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().during().dates(new Date(), new Date(System.currentTimeMillis() + 10000000));
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().during().next(1000);
    filter.accept(visitor, null);
    filter = builder.attribute(FOO_ATTRIBUTE).is().during().last(1000);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(6)).visit(isA(During.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) Date(java.util.Date) During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Example 44 with FilterBuilder

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

the class FilterBuilderTest method withinBuffer.

@Test
public void withinBuffer() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).withinBuffer().wkt(POINT_WKT);
    filter.accept(visitor, null);
    filter = builder.attribute(Metacard.GEOGRAPHY).withinBuffer().wkt(POINT_WKT, 123.45d);
    filter.accept(visitor, null);
    filter = builder.attribute(Metacard.GEOGRAPHY).is().withinBuffer().wkt(POINT_WKT);
    filter.accept(visitor, null);
    filter = builder.attribute(Metacard.GEOGRAPHY).is().withinBuffer().wkt(POINT_WKT, 123.45d);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(4)).visit(isA(DWithin.class), any());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DWithin(org.opengis.filter.spatial.DWithin) 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 45 with FilterBuilder

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

the class FilterBuilderTest method xpathExists.

@Test
public void xpathExists() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.xpath("//foo").exists();
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(PropertyIsLike.class), any());
}
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)

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