SearchUserViewModel extends BaseObservable { public void destroy(Boolean unsubsricbe) { fragmentListener = null; if(unsubsricbe) { searchUserUseCase.unsubscribe(); } } @Inject  SearchUserViewModel(@Named("searchUser") UseCase searchUserUseCase); void setFragmentListener(FragmentListener fragmentListener); TextWatcher getUsernameTextWatcher(); boolean onSearchAction(TextView view, int actionId, KeyEvent event); void onClickSearch(View view); void destroy(Boolean unsubsricbe); void setUsername(String username); ObservableInt getProgressVisibility(); ObservableInt getUserListVisibility(); final ObservableInt progressVisibility; final ObservableInt userListVisibility; }
@Test public void onDestroyTrueShouldUnsubscribeFromUseCase() { searchUserViewModel.destroy(true); verify(mockSearchUserUseCase).unsubscribe(); }
@Test public void onDestroyFalseShouldNotUnsubscribeFromUseCase() { searchUserViewModel.destroy(false); verifyZeroInteractions(mockSearchUserUseCase); }