RepositoryAdapter extends RecyclerView.Adapter<ViewHolder> implements Updatable { @NonNull public static Builder repositoryAdapter() { return new Builder(); } RepositoryAdapter(@NonNull final Builder builder); @NonNull static Builder repositoryAdapter(); final void startObserving(); final void stopObserving(); @Override final void update(); @Override final int getItemCount(); @Override final int getItemViewType(final int position); @Override final long getItemId(final int position); @Override ViewHolder onCreateViewHolder(final ViewGroup parent,
      final int layoutResourceId); @Override final void onBindViewHolder(final ViewHolder holder, final int position); @Override boolean onFailedToRecycleView(final ViewHolder holder); @Override void onViewRecycled(final ViewHolder holder);  }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForAdapterWithoutRepositories() { repositoryAdapter() .addAdditionalObservable(updateDispatcher) .build(); }
@Test public void shouldDoNothingOnActivityCreatedForWhileResumed() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileResumed(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToCreated(); }
@Test public void shouldDoNothingOnActivityDestroyedForWhileResumed() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileResumed(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToDestroyed(); }
@Test public void shouldDoNothingOnActivityCreatedForWhileStarted() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileStarted(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToCreated(); }
@Test public void shouldDoNothingOnActivityDestroyedForWhileStarted() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileStarted(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToDestroyed(); }
@Test public void shouldDoNothingOnActivityStoppedForWhileResumed() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileResumed(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToStopped(); }
@Test public void shouldDoNothingOnActivityStartedForWhileResumed() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileResumed(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToStarted(); }
@Test public void shouldDoNothingOnActivityResumedForWhileStarted() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileStarted(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToResumed(); }
@Test public void shouldDoNothingOnActivityPausedForWhileStarted() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileStarted(activity); runUiThreadTasksIncludingDelayedTasks(); setActivityToPaused(); }
@Test public void shouldDoNothingOnSaveInstanceStateForWhileResumed() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileResumed(activity); runUiThreadTasksIncludingDelayedTasks(); saveActivityInstanceState(); }
@Test public void shouldDoNothingOnSaveInstanceStateForWhileStarted() { repositoryAdapterWhileResumed = repositoryAdapter() .add(repository, repositoryPresenter) .add(secondRepository, secondRepositoryPresenter) .addAdditionalObservable(updateDispatcher) .whileStarted(activity); runUiThreadTasksIncludingDelayedTasks(); saveActivityInstanceState(); }