Search in sources :

Example 1 with GeotoolsFilterBuilder

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

the class DumpCommandTest method testNormalOperation.

/**
     * Check for normal operation
     *
     * @throws Exception
     */
@Test
public void testNormalOperation() throws Exception {
    // given
    DumpCommand dumpCommand = new DumpCommand();
    dumpCommand.catalogFramework = givenCatalogFramework(getResultList("id1", "id2"));
    dumpCommand.filterBuilder = new GeotoolsFilterBuilder();
    File outputDirectory = testFolder.newFolder("somedirectory");
    String outputDirectoryPath = outputDirectory.getAbsolutePath();
    dumpCommand.dirPath = outputDirectoryPath;
    dumpCommand.transformerId = CatalogCommands.SERIALIZED_OBJECT_ID;
    // when
    dumpCommand.executeWithSubject();
    // then
    assertThat(consoleOutput.getOutput(), containsString(" 2 file(s) dumped in "));
}
Also used : GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 2 with GeotoolsFilterBuilder

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

the class DumpCommandTest method testNormalOperationWithContent.

/**
     * Check for normal operation when there is local content associated with metacards
     *
     * @throws Exception
     */
@Test
public void testNormalOperationWithContent() throws Exception {
    // given
    List<Result> resultList = getResultList("id1", "id2");
    MetacardImpl metacard1 = new MetacardImpl(resultList.get(0).getMetacard());
    MetacardImpl metacard2 = new MetacardImpl(resultList.get(1).getMetacard());
    metacard1.setResourceURI(new URI("content:" + metacard1.getId()));
    metacard2.setResourceURI(new URI("content:" + metacard2.getId() + "#preview"));
    DumpCommand dumpCommand = new DumpCommand();
    dumpCommand.catalogFramework = givenCatalogFramework(resultList);
    dumpCommand.filterBuilder = new GeotoolsFilterBuilder();
    File outputDirectory = testFolder.newFolder("somedirectory");
    String outputDirectoryPath = outputDirectory.getAbsolutePath();
    dumpCommand.dirPath = outputDirectoryPath;
    dumpCommand.transformerId = CatalogCommands.SERIALIZED_OBJECT_ID;
    // when
    dumpCommand.executeWithSubject();
    // then
    assertThat(consoleOutput.getOutput(), containsString(" 2 file(s) dumped in "));
}
Also used : GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) URI(java.net.URI) File(java.io.File) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 3 with GeotoolsFilterBuilder

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

the class DumpCommandTest method testNormalOperationNoFiles.

/**
     * Check for normal operation without any files
     *
     * @throws Exception
     */
@Test
public void testNormalOperationNoFiles() throws Exception {
    // given
    DumpCommand dumpCommand = new DumpCommand();
    dumpCommand.catalogFramework = givenCatalogFramework(getEmptyResultList());
    dumpCommand.filterBuilder = new GeotoolsFilterBuilder();
    File outputDirectory = testFolder.newFolder("somedirectory");
    String outputDirectoryPath = outputDirectory.getAbsolutePath();
    dumpCommand.dirPath = outputDirectoryPath;
    dumpCommand.transformerId = CatalogCommands.SERIALIZED_OBJECT_ID;
    // when
    dumpCommand.executeWithSubject();
    // then
    String expectedPrintOut = " 0 file(s) dumped in ";
    assertThat(consoleOutput.getOutput(), startsWith(expectedPrintOut));
}
Also used : GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 4 with GeotoolsFilterBuilder

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

the class RemoveAllCommandTest method testExecuteWithSubject.

/**
     * Checks the forced (-f) generic case.
     *
     * @throws Exception
     */
@Test
public void testExecuteWithSubject() throws Exception {
    // given
    RemoveAllCommand removeAllCommand = new RemoveAllCommand();
    final CatalogFramework catalogFramework = mock(CatalogFramework.class);
    QueryResponse queryResponse = mock(QueryResponse.class);
    when(queryResponse.getResults()).thenReturn(getResultList(10));
    when(catalogFramework.query(isA(QueryRequest.class))).thenReturn(queryResponse);
    DeleteResponse deleteResponse = mock(DeleteResponse.class);
    when(deleteResponse.getDeletedMetacards()).thenReturn(getMetacardList(10));
    when(catalogFramework.delete(isA(DeleteRequest.class))).thenReturn(deleteResponse);
    removeAllCommand.catalogFramework = catalogFramework;
    removeAllCommand.filterBuilder = new GeotoolsFilterBuilder();
    removeAllCommand.batchSize = 11;
    removeAllCommand.force = true;
    // when
    removeAllCommand.executeWithSubject();
    // then
    verify(catalogFramework, times(1)).delete(isA(DeleteRequest.class));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) QueryRequest(ddf.catalog.operation.QueryRequest) QueryResponse(ddf.catalog.operation.QueryResponse) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) CatalogFramework(ddf.catalog.CatalogFramework) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 5 with GeotoolsFilterBuilder

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

the class LatestCommandTest method testNoTitle.

/**
     * When no title is provided, output should still be displayed.
     *
     * @throws Exception
     */
@Test
public void testNoTitle() throws Exception {
    // given
    LatestCommand latestCommand = new LatestCommand();
    latestCommand.catalogFramework = givenCatalogFramework(getResultList("id1", "id2"));
    latestCommand.filterBuilder = new GeotoolsFilterBuilder();
    // when
    latestCommand.executeWithSubject();
    // then
    assertThat(consoleOutput.getOutput(), containsString("id1"));
    assertThat(consoleOutput.getOutput(), containsString("id2"));
}
Also used : 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