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 "));
}
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 "));
}
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));
}
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));
}
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"));
}
Aggregations