@Test public void shouldCollectAndSortStatistics() throws ExecutionException, InterruptedException { List<QueryStats> report = queue.getReportSortedBy("avg"); a(report.get(0).getQuery()).shouldBeEqual("test2"); a(report.get(0).getAvg()).shouldBeEqual(35); a(report.get(0).getTotal()).shouldBeEqual(345); a(report.get(0).getCount()).shouldBeEqual(10); a(report.get(0).getMin()).shouldBeEqual(30); a(report.get(0).getMax()).shouldBeEqual(39); a(report.get(1).getQuery()).shouldBeEqual("test1"); a(report.get(1).getAvg()).shouldBeEqual(25); a(report.get(1).getTotal()).shouldBeEqual(245); a(report.get(1).getCount()).shouldBeEqual(10); a(report.get(1).getMin()).shouldBeEqual(20); a(report.get(1).getMax()).shouldBeEqual(29); a(report.get(2).getQuery()).shouldBeEqual("test"); a(report.get(2).getAvg()).shouldBeEqual(15); a(report.get(2).getTotal()).shouldBeEqual(145); a(report.get(2).getCount()).shouldBeEqual(10); a(report.get(2).getMin()).shouldBeEqual(10); a(report.get(2).getMax()).shouldBeEqual(19); }
public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQuery.values()); Collections.sort(res, sortBy.getComparator()); return res; }
StatisticsQueue { public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQuery.values()); Collections.sort(res, sortBy.getComparator()); return res; } }
StatisticsQueue { public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQuery.values()); Collections.sort(res, sortBy.getComparator()); return res; } StatisticsQueue(boolean paused); }
StatisticsQueue { public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQuery.values()); Collections.sort(res, sortBy.getComparator()); return res; } StatisticsQueue(boolean paused); boolean isPaused(); void stop(); void pause(boolean val); Future enqueue(final QueryExecutionEvent event); void reset(); List<QueryStats> getReportSortedBy(String sortByVal); }
StatisticsQueue { public List<QueryStats> getReportSortedBy(String sortByVal) { SortBy sortBy; try { sortBy = SortBy.valueOf(sortByVal); } catch (Exception e) { throw new IllegalArgumentException("allowed values are: " + Arrays.toString(SortBy.values())); } List<QueryStats> res = new ArrayList<>(statsByQuery.values()); Collections.sort(res, sortBy.getComparator()); return res; } StatisticsQueue(boolean paused); boolean isPaused(); void stop(); void pause(boolean val); Future enqueue(final QueryExecutionEvent event); void reset(); List<QueryStats> getReportSortedBy(String sortByVal);  }