TasksViewModel extends BaseViewModel<TasksViewModel.State> { protected void onCompleteTaskItemClick(Task task) { manageSubscription(mTaskService.complete(task.getId()) .compose(Transformer.applyComputationScheduler()) .subscribe(aVoid -> setState(State.COMPLETE_TASK), Throwable::printStackTrace), UnsubscribeLifeCycle.DESTROY); } TasksViewModel(); @Override void onCreate(); List<Task> getTasks(); void reloadData();  }
@Test public void testOnCompleteTaskItemClick() throws Exception { Task task = new Task("title", "description"); doReturn(Observable.just(null)).when(mTasksViewModel.mTaskService).complete(anyString()); mTasksViewModel.onCompleteTaskItemClick(task); verify(mTasksViewModel, times(1)).setState(eq(TasksViewModel.State.COMPLETE_TASK)); }