BookmarksPresenter extends BasePresenter<BookmarksView> { void removeBookmarks() { for (Bookmark bookmark : bookmarks) { bookmarksManager.delete(bookmark); } updateBookmarks(null); changeListener.onBookmarksUpdate(); } @Inject  BookmarksPresenter(BookmarksManager bookmarksManager, Librarian myLibrarian); @Override void onViewCreated();  }
@Test public void removeBookmarks() throws Exception { doAnswer(invocation -> { when(bookmarksManager.getAll(isNull())).thenReturn(Collections.emptyList()); return null; }).when(bookmarksManager).delete(any(Bookmark.class)); presenter.setChangeListener(changeListener); presenter.onRefresh(); Mockito.reset(view); presenter.removeBookmarks(); verify(view).updateBookmarks(bmCaptor.capture()); verify(changeListener).onBookmarksUpdate(); List<Bookmark> bookmarks = bmCaptor.getValue(); assertNotNull(bookmarks); assertThat(bookmarks.size(), equalTo(0)); }