SearchUserPresenter implements Presenter<SearchUserView> { @Override public void destroy(boolean unsubscribe) { searchUserView = null; if(unsubscribe) { searchUserUseCase.unsubscribe(); } } @Inject  SearchUserPresenter(@Named("searchUser") UseCase searchUserUseCase); @Override void attachView(SearchUserView searchUserView); void loadUsers(String username); void onUserClick(String username); @Override void detachView(); @Override void destroy(boolean unsubscribe);  }
@Test public void destroyShouldUnsubscribeIfTrue() { searchUserPresenter = new SearchUserPresenter(mockSearchUserUseCase); searchUserPresenter.destroy(true); verify(mockSearchUserUseCase).unsubscribe(); }
@Test public void destroyShouldNotUnsubScribeIfFalse() { searchUserPresenter = new SearchUserPresenter(mockSearchUserUseCase); searchUserPresenter.destroy(false); verifyZeroInteractions(mockSearchUserUseCase); }