@Test public void shouldNotAddCategoryAndNotifyViewWhenCategoryInputIsEmpty() throws Exception { when(view.getCategory()).thenReturn(""); assertFalse(presenter.addCategory()); verifyNoMoreInteractions(database); verify(view).displayError(); }
public boolean addCategory() { String newCategory = view.getCategory(); if(newCategory.isEmpty()){ view.displayError(); return false; } database.addExpenseType(new ExpenseType(newCategory)); return true; }
CategoryPresenter { public boolean addCategory() { String newCategory = view.getCategory(); if(newCategory.isEmpty()){ view.displayError(); return false; } database.addExpenseType(new ExpenseType(newCategory)); return true; } }
CategoryPresenter { public boolean addCategory() { String newCategory = view.getCategory(); if(newCategory.isEmpty()){ view.displayError(); return false; } database.addExpenseType(new ExpenseType(newCategory)); return true; } CategoryPresenter(AddCategoryView view, ExpenseDatabaseHelper database); }
CategoryPresenter { public boolean addCategory() { String newCategory = view.getCategory(); if(newCategory.isEmpty()){ view.displayError(); return false; } database.addExpenseType(new ExpenseType(newCategory)); return true; } CategoryPresenter(AddCategoryView view, ExpenseDatabaseHelper database); boolean addCategory(); }
CategoryPresenter { public boolean addCategory() { String newCategory = view.getCategory(); if(newCategory.isEmpty()){ view.displayError(); return false; } database.addExpenseType(new ExpenseType(newCategory)); return true; } CategoryPresenter(AddCategoryView view, ExpenseDatabaseHelper database); boolean addCategory();  }