@Test public void shouldAddCategoryToTheDatabaseAndNotify() throws Exception { when(view.getCategory()).thenReturn("Movie"); ArgumentCaptor<ExpenseType> expenseTypeCaptor = ArgumentCaptor.forClass(ExpenseType.class); assertTrue(presenter.addCategory()); verify(database).addExpenseType(expenseTypeCaptor.capture()); ExpenseType expenseType = expenseTypeCaptor.getValue(); assertThat(expenseType.getType(), is("Movie")); }
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();  }