### Question:
TranslationPresenter { void toggleFavorite() { if (model != null) { boolean isFavourite = !model.isFavourite(); model.setFavourite(isFavourite); sozlikDao.update(model); translationView.showFavorite(isFavourite); } } TranslationPresenter(SozlikDao sozlikDao);   }### Answer:
@Test public void whenWordIsFavoritedToggleRemovesFromFavorites() { when(sozlikDbModelMock.isFavourite()).thenReturn(true); translationPresenter.toggleFavorite(); verify(sozlikDaoMock, times(1)).update(sozlikDbModelMock); verify(translationViewMock, times(1)).showFavorite(false); verify(sozlikDbModelMock, times(1)).setFavourite(false); verifyNoMoreInteractions(translationViewMock); }
@Test public void whenWordIsNotFavoritedToggleAddsToFavorites() { when(sozlikDbModelMock.isFavourite()).thenReturn(false); translationPresenter.toggleFavorite(); verify(sozlikDaoMock, times(1)).update(sozlikDbModelMock); verify(translationViewMock, times(1)).showFavorite(true); verify(sozlikDbModelMock, times(1)).setFavourite(true); verifyNoMoreInteractions(translationViewMock); }