UserDetailsPresenter implements Presenter<UserDetailsView> { @Override public void destroy(boolean unsubscribe) { userDetailsView = null; if(unsubscribe) { loadUserDetailsUseCase.unsubscribe(); } } @Inject  UserDetailsPresenter(@Named("userDetails") UseCase loadUserDetailsUseCase); @Override void attachView(UserDetailsView userDetailsView); void loadRepositories(String username); @Override void detachView(); @Override void destroy(boolean unsubscribe);  }
@Test public void destroyShouldUnsubscribeIfTrue() { userDetailsPresenter = new UserDetailsPresenter(mockLoadUserDetailsUseCase); userDetailsPresenter.destroy(true); verify(mockLoadUserDetailsUseCase).unsubscribe(); }
@Test public void destroyShouldNotUnsubScribeIfFalse() { userDetailsPresenter = new UserDetailsPresenter(mockLoadUserDetailsUseCase); userDetailsPresenter.destroy(false); verifyZeroInteractions(mockLoadUserDetailsUseCase); }