Search in sources :

Example 36 with GeotoolsFilterBuilder

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

the class FilterBuilderTest method likeFuzzy.

@Test
public void likeFuzzy() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(FOO_ATTRIBUTE).is().like().fuzzyText("bar");
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(PropertyIsLike.class), anyObject());
// TODO check for fuzzy
}
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 37 with GeotoolsFilterBuilder

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

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

the class FilterBuilderTest method orNull.

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

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

the class CachingFederationStrategyTest method setup.

@Before
public void setup() throws Exception {
    cacheExecutor = MoreExecutors.newDirectExecutorService();
    queryExecutor = MoreExecutors.newDirectExecutorService();
    preQueryPlugin = mock(PreFederatedQueryPlugin.class);
    when(preQueryPlugin.process(any(), any())).thenAnswer(invocation -> invocation.getArguments()[1]);
    clientAdaptor = mock(SolrClientAdaptor.class);
    cache = mock(SolrCache.class);
    cacheBulkProcessor = mock(CacheBulkProcessor.class);
    cacheCommitPhaser = mock(CacheCommitPhaser.class);
    cacheArgs = ArgumentCaptor.forClass((Class) List.class);
    validationQueryFactory = mock(ValidationQueryFactory.class);
    strategy = new CachingFederationStrategy(queryExecutor, Arrays.asList(preQueryPlugin), new ArrayList<>(), cache, cacheExecutor, validationQueryFactory, new CacheQueryFactory(new GeotoolsFilterBuilder()));
    mockSortedQueryMonitorFactory = mock(SortedQueryMonitorFactory.class);
    mockSortedQueryMonitor = mock(SortedQueryMonitor.class);
    responseArgumentCaptor = ArgumentCaptor.forClass(QueryResponseImpl.class);
    requestArgumentCaptor = ArgumentCaptor.forClass(QueryRequestImpl.class);
    when(mockSortedQueryMonitorFactory.createMonitor(any(CompletionService.class), any(Map.class), responseArgumentCaptor.capture(), requestArgumentCaptor.capture(), any(List.class))).thenReturn(mockSortedQueryMonitor);
    strategy.setSortedQueryMonitorFactory(mockSortedQueryMonitorFactory);
    strategy.setCacheCommitPhaser(cacheCommitPhaser);
    strategy.setCacheBulkProcessor(cacheBulkProcessor);
    mockQuery = mock(Query.class);
    when(mockQuery.getTimeoutMillis()).thenReturn(LONG_TIMEOUT);
    when(mockQuery.getPageSize()).thenReturn(-1);
    mockMetacard = new MetacardImpl();
    mockMetacard.setId("mock metacard");
    mockResult = new ResultImpl(mockMetacard);
    mockResponse = mock(SourceResponse.class);
    results = Arrays.asList(mockResult);
    when(mockResponse.getResults()).thenReturn(results);
    // Set general properties
    properties = new HashMap<>();
    properties.put(QUERY_MODE, NATIVE_QUERY_MODE);
}
Also used : PreFederatedQueryPlugin(ddf.catalog.plugin.PreFederatedQueryPlugin) Query(ddf.catalog.operation.Query) SourceResponse(ddf.catalog.operation.SourceResponse) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) CompletionService(java.util.concurrent.CompletionService) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 40 with GeotoolsFilterBuilder

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

the class CopyFilterDelegateTest method assertFilterException.

private void assertFilterException(Filter filterIn) {
    FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
    FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    // the UnsupportedQueryException thrown by the FilterAdapter.
    try {
        fa.adapt(filterIn, delegate);
        fail("Should have gotten an UnsupportedQueryException");
    } catch (UnsupportedQueryException e) {
        assertTrue(e.getCause() instanceof UnsupportedOperationException);
    }
}
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)

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