Search in sources :

Example 41 with GeotoolsFilterBuilder

use of ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder in project ddf by codice.

the class FilterBuilderTest method intersects.

@Test
public void intersects() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(POINT_WKT);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(Intersects.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) Intersects(org.opengis.filter.spatial.Intersects) Test(org.junit.Test)

Example 42 with GeotoolsFilterBuilder

use of ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder in project ddf by codice.

the class CopyFilterDelegateTest method testExcludeFilter.

@Test
public void testExcludeFilter() {
    Filter filterIn = Filter.EXCLUDE;
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    Filter filterCopy = null;
    try {
        filterCopy = fa.adapt(filterIn, delegate);
    } catch (UnsupportedQueryException e) {
        fail(e.getMessage());
    }
    assertNotNull(filterCopy);
    assertSame(filterIn, filterCopy);
}
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) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Test(org.junit.Test)

Example 43 with GeotoolsFilterBuilder

use of ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder in project ddf by codice.

the class FilterBuilderTest method isDate.

@Test
public void isDate() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).is().date(new Date());
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(PropertyIsEqualTo.class), anyObject());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) 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) Date(java.util.Date) Test(org.junit.Test)

Example 44 with GeotoolsFilterBuilder

use of ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder 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), anyObject());
}
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 GeotoolsFilterBuilder

use of ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder 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)

Aggregations

GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)67 Test (org.junit.Test)50 FilterBuilder (ddf.catalog.filter.FilterBuilder)44 Filter (org.opengis.filter.Filter)38 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)24 FilterVisitor (org.opengis.filter.FilterVisitor)23 InOrder (org.mockito.InOrder)21 ArrayList (java.util.ArrayList)14 Date (java.util.Date)13 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)12 QueryRequest (ddf.catalog.operation.QueryRequest)10 QueryResponse (ddf.catalog.operation.QueryResponse)9 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)9 CatalogFramework (ddf.catalog.CatalogFramework)8 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 Metacard (ddf.catalog.data.Metacard)7 FilterAdapter (ddf.catalog.filter.FilterAdapter)7 Source (ddf.catalog.source.Source)7 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)7 Before (org.junit.Before)7