DisplayerCoordinator { public void drawAll() { drawAll(null, null); } @Inject  DisplayerCoordinator(RendererManager rendererManager); void addListener(DisplayerListener... listeners); void addDisplayers(Collection<Displayer> displayers); void addDisplayers(Displayer... displayers); void addDisplayer(Displayer displayer); List<Displayer> getDisplayerList(); boolean removeDisplayer(Displayer displayer); void drawAll(); void redrawAll(); void drawAll(Command onSuccess, Command onFailure); void redrawAll(Command onSuccess, Command onFailure); void closeAll(); void clear(); void addNotificationVeto(Displayer target, List<Displayer> vetoedDisplayers); void addNotificationVeto(List<Displayer> vetoedDisplayers); boolean isNotificationVetoed(Displayer from, Displayer to);  }
@Test public void testDrawAll() { displayerCoordinator.drawAll(); verify(listener, times(5)).onDataLookup(any(Displayer.class)); verify(listener, times(5)).onDraw(any(Displayer.class)); }
@Test public void testFilterPropagations() { displayerCoordinator.drawAll(); reset(listener); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 0); DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 19); verify(listener).onDataLookup(allRowsTable); verify(listener).onRedraw(allRowsTable); }
@Test public void testFilterReset() { displayerCoordinator.drawAll(); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 0); List<Interval> deptIntervalList = deptPieChart.filterIntervals(COLUMN_DEPARTMENT); assertEquals(deptIntervalList.size(), 1); Interval deptInterval = deptIntervalList.get(0); deptSelector.filterUpdate(COLUMN_DEPARTMENT, 1); DataSet dataSet = deptPieChart.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 1); assertEquals(deptPieChart.filterIndexes(COLUMN_DEPARTMENT).size(), 1); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, deptInterval.getIndex()); deptIntervalList = deptPieChart.filterIntervals(COLUMN_DEPARTMENT); assertEquals(deptIntervalList.size(), 0); }
@Test public void testQuarterFilter() { displayerCoordinator.drawAll(); reset(listener); quarterPieChart.filterUpdate(COLUMN_DATE, 0); DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 10); for (int i = 0; i < dataSet.getRowCount(); i++) { Date d = (Date) dataSet.getValueAt(i, COLUMN_DATE); assertTrue(d.getMonth() > 8); } verify(listener).onDataLookup(allRowsTable); verify(listener).onRedraw(allRowsTable); }
@Test public void testYearFilter() { displayerCoordinator.drawAll(); reset(listener); yearBarChart.filterUpdate(COLUMN_DATE, 2); DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 11); for (int i = 0; i < dataSet.getRowCount(); i++) { Date d = (Date) dataSet.getValueAt(i, COLUMN_DATE); assertEquals(d.getYear(), 114); } verify(listener).onDataLookup(allRowsTable); verify(listener).onRedraw(allRowsTable); }
@Test public void testMultipleFilter() { displayerCoordinator.drawAll(); yearBarChart.filterUpdate(COLUMN_DATE, 2); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 1); DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); assertEquals(dataSet.getRowCount(), 2); }
@Test public void testFilterWithNull() { DataSet expensesDataSet = clientDataSetManager.getDataSet(EXPENSES); int column = expensesDataSet.getColumnIndex(expensesDataSet.getColumnById(COLUMN_DEPARTMENT)); expensesDataSet.setValueAt(0, column, null); displayerCoordinator.drawAll(); reset(listener); deptPieChart.filterUpdate(COLUMN_DEPARTMENT, 1); DataSet dataSet = allRowsTable.getDataSetHandler().getLastDataSet(); verify(listener, never()).onError(any(Displayer.class), any(ClientRuntimeError.class)); verify(listener).onDataLookup(allRowsTable); verify(listener).onRedraw(allRowsTable); assertEquals(dataSet.getRowCount(), 18); }