@Test public void shouldRenderTheGraphWithRightPoints() throws Exception { Expense food = new Expense(100l, "Food", "01-10-2015"); when(database.getExpensesForCurrentMonthGroupByCategory()).thenReturn(asList(food)); CurrentMonthExpensePresenter presenter = new CurrentMonthExpensePresenter(view, database); ArgumentCaptor<List> pointsCaptor = ArgumentCaptor.forClass(List.class); presenter.plotGraph(); verify(view).getGraphColor(); verify(view).displayGraph(pointsCaptor.capture()); List points = pointsCaptor.getValue(); assertThat(points.size(), is(1)); assertThat(((Bar)points.get(0)).getName(), is(food.getType())); assertThat(((Bar)points.get(0)).getValue(), is(food.getAmount().floatValue())); }
public void plotGraph() { List<Bar> points = new ArrayList<Bar>(); for (Expense expense : expenseCollection.withoutMoneyTransfer()) { Bar bar = new Bar(); bar.setColor(view.getGraphColor()); bar.setName(expense.getType()); bar.setValue(expense.getAmount()); points.add(bar); } view.displayGraph(points); }
CurrentMonthExpensePresenter { public void plotGraph() { List<Bar> points = new ArrayList<Bar>(); for (Expense expense : expenseCollection.withoutMoneyTransfer()) { Bar bar = new Bar(); bar.setColor(view.getGraphColor()); bar.setName(expense.getType()); bar.setValue(expense.getAmount()); points.add(bar); } view.displayGraph(points); } }
CurrentMonthExpensePresenter { public void plotGraph() { List<Bar> points = new ArrayList<Bar>(); for (Expense expense : expenseCollection.withoutMoneyTransfer()) { Bar bar = new Bar(); bar.setColor(view.getGraphColor()); bar.setName(expense.getType()); bar.setValue(expense.getAmount()); points.add(bar); } view.displayGraph(points); } CurrentMonthExpensePresenter(CurrentMonthExpenseView view, ExpenseDatabaseHelper database); }
CurrentMonthExpensePresenter { public void plotGraph() { List<Bar> points = new ArrayList<Bar>(); for (Expense expense : expenseCollection.withoutMoneyTransfer()) { Bar bar = new Bar(); bar.setColor(view.getGraphColor()); bar.setName(expense.getType()); bar.setValue(expense.getAmount()); points.add(bar); } view.displayGraph(points); } CurrentMonthExpensePresenter(CurrentMonthExpenseView view, ExpenseDatabaseHelper database); void plotGraph(); void showTotalExpense(); }
CurrentMonthExpensePresenter { public void plotGraph() { List<Bar> points = new ArrayList<Bar>(); for (Expense expense : expenseCollection.withoutMoneyTransfer()) { Bar bar = new Bar(); bar.setColor(view.getGraphColor()); bar.setName(expense.getType()); bar.setValue(expense.getAmount()); points.add(bar); } view.displayGraph(points); } CurrentMonthExpensePresenter(CurrentMonthExpenseView view, ExpenseDatabaseHelper database); void plotGraph(); void showTotalExpense();  }