@Test public void shouldNotAddExpenseAndNotifyViewWhenAmountIsEmpty() throws Exception { when(view.getAmount()).thenReturn(""); when(view.getType()).thenReturn("Food"); assertFalse(presenter.addExpense()); verify(view).displayError(); verifyNoMoreInteractions(database); }
public boolean addExpense() { String amount = view.getAmount(); if(amount.isEmpty()) { view.displayError(); return false; } Expense expense = new Expense(Long.valueOf(amount), view.getType(), getCurrentDate()); database.addExpense(expense); return true; }
ExpensePresenter { public boolean addExpense() { String amount = view.getAmount(); if(amount.isEmpty()) { view.displayError(); return false; } Expense expense = new Expense(Long.valueOf(amount), view.getType(), getCurrentDate()); database.addExpense(expense); return true; } }
ExpensePresenter { public boolean addExpense() { String amount = view.getAmount(); if(amount.isEmpty()) { view.displayError(); return false; } Expense expense = new Expense(Long.valueOf(amount), view.getType(), getCurrentDate()); database.addExpense(expense); return true; } ExpensePresenter(ExpenseDatabaseHelper expenseDatabaseHelper, ExpenseView view); }
ExpensePresenter { public boolean addExpense() { String amount = view.getAmount(); if(amount.isEmpty()) { view.displayError(); return false; } Expense expense = new Expense(Long.valueOf(amount), view.getType(), getCurrentDate()); database.addExpense(expense); return true; } ExpensePresenter(ExpenseDatabaseHelper expenseDatabaseHelper, ExpenseView view); boolean addExpense(); void setExpenseTypes(); }
ExpensePresenter { public boolean addExpense() { String amount = view.getAmount(); if(amount.isEmpty()) { view.displayError(); return false; } Expense expense = new Expense(Long.valueOf(amount), view.getType(), getCurrentDate()); database.addExpense(expense); return true; } ExpensePresenter(ExpenseDatabaseHelper expenseDatabaseHelper, ExpenseView view); boolean addExpense(); void setExpenseTypes();  }