ConfigurationService { public Map<String, Object> getStats() throws DatabaseException { Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> documentMap = new HashMap<String, Object>(); DatabaseConnector<T> databaseConnector = null; PipelineScanner<T> scanner = null; try { databaseConnector = getConnector(); scanner = getPipelineScanner(); } catch (IOException e) { throw new DatabaseException("Failed to connect to database", e); } DocumentReader<T> documentReader = databaseConnector.getDocumentReader(); PipelineStatus<T> pipelineStatus = databaseConnector.getStatusReader().getStatus(); documentMap.put("current", documentReader.getActiveDatabaseSize()); documentMap.put("throughput", 0); documentMap.put("archived", documentReader.getInactiveDatabaseSize()); documentMap.put("processed", pipelineStatus.getProcessedCount()); documentMap.put("discarded", pipelineStatus.getDiscardedCount()); documentMap.put("failed", pipelineStatus.getFailedCount()); map.put("documents", documentMap); Map<String, Object> stageMap = new HashMap<String, Object>(); map.put("groups", stageMap); PipelineReader pipelineReader = databaseConnector.getPipelineReader(); stageMap.put("active", scanner.getStageConfigMap(pipelineReader.getPipeline())); stageMap.put("debug", scanner.getStageConfigMap(pipelineReader.getDebugPipeline())); return map; } ConfigurationService(DatabaseConnector<T> connector); void addLibrary(String id, String filename, InputStream stream); Map<String, Object> getLibraries(); Map<String, Object> getLibrary(String id); @SuppressWarnings("unchecked") void addStageParameters(Stage stage, String stageGroupName); Map<String, Object> getStats();  }
@Test public void testGetStats() throws DatabaseException { Map<String, Object> stats = service.getStats(); verify(pipelineReader).getPipeline(); verify(pipelineReader).getDebugPipeline(); verify(documentReader).getActiveDatabaseSize(); verify(documentReader).getInactiveDatabaseSize(); assertTrue(stats.containsKey("documents")); assertTrue(stats.containsKey("groups")); assertEquals(2, stats.size()); }