use of org.codice.ddf.resourcemanagement.query.plugin.ActiveSearch in project ddf by codice.
the class PrintActiveSearchesCommand method printActiveSearchesToConsole.
/**
* Called by the execute method when the catalog:printacticesearches command is called by the shell.
* Loops through the {@link ActiveSearch} {@link Map} to print a formatted table representation
* of all {@link ActiveSearch}'s in the {@link ActiveSearch} {@link Map}
*/
void printActiveSearchesToConsole() {
if (queryMonitor == null) {
LOGGER.debug("QueryMonitorImpl not yet instantiated. Cannot printActiveSearchesToConsole().");
return;
}
Map<UUID, ActiveSearch> activeSearchMap = queryMonitor.getActiveSearches();
console.println();
String colorString = Ansi.ansi().fg(Ansi.Color.CYAN).toString();
console.print(colorString);
console.print(String.format(FORMAT_STRING, "User Info", "Source", "Search Criteria", "Start Time", "Unique ID"));
console.println(Ansi.ansi().reset().toString());
if (activeSearchMap == null) {
LOGGER.debug("Retrieving ActiveSearch information from queryMonitor returned null. Cannot printActiveSearchesToConsole().");
return;
}
for (ActiveSearch as : activeSearchMap.values()) {
console.print(as.toFormattedString());
}
}
use of org.codice.ddf.resourcemanagement.query.plugin.ActiveSearch in project ddf by codice.
the class MonitorCommandsTest method testPrintSearchTableToConsole.
@Test
public void testPrintSearchTableToConsole() {
final ByteArrayOutputStream[] baos = new ByteArrayOutputStream[1];
PrintActiveSearchesCommand printCommand = new PrintActiveSearchesCommand(qmpi) {
@Override
PrintStream getPrintStream() {
baos[0] = new ByteArrayOutputStream();
return new PrintStream(baos[0]);
}
};
qmpi.setRemoveSearchAfterComplete(false);
UUID u = UUID.randomUUID();
ActiveSearch as = new ActiveSearch(QUERY_TEXT, null, u, CLIENT_TEXT);
qmpi.addActiveSearch(as);
printCommand.printActiveSearchesToConsole();
assertThat(baos[0].toString(), containsString(QUERY_TEXT));
assertThat(baos[0].toString(), containsString(u.toString()));
}
use of org.codice.ddf.resourcemanagement.query.plugin.ActiveSearch in project ddf by codice.
the class TestQueryMonitor method generateActiveSearch.
private ActiveSearch generateActiveSearch(String name, String uuid) {
Source source = mock(Source.class);
doReturn(SOURCE).when(source).getId();
Date date = new Date();
ActiveSearch activeSearch = mock(ActiveSearch.class);
doReturn(source).when(activeSearch).getSource();
doReturn(name).when(activeSearch).getClientInfo();
doReturn(CQL).when(activeSearch).getCQL();
doReturn(date).when(activeSearch).getStartTime();
doReturn(UUID.fromString(uuid)).when(activeSearch).getUniqueID();
return activeSearch;
}
Aggregations