DynamicRecyclerViewAdapter extends RecyclerView.Adapter { public abstract void onBindViewHolder(@NonNull ViewHolder holder, @NonNull DataObject item, int position);  abstract ViewHolder onCreateViewHolder(@NonNull ViewGroup parent); abstract TitleViewHolder onCreateTitleViewHolder(@NonNull ViewGroup parent); abstract void onBindViewHolder(@NonNull ViewHolder holder, @NonNull DataObject item, int position); abstract void onBindTitleViewHolder(@NonNull TitleViewHolder holder,
                                               @NonNull String sectionName,
                                               @NonNull Collection<DataObject> dataItems,
                                               int position); @Override final RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType); @Override final void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position); @Override final int getItemViewType(int position); @Override final int getItemCount(); final void setData(@Nullable Collection<DataObject> items,
                              @NonNull SectionEvaluator<DataObject> sectionEvaluator); final void setData(@Nullable Collection<DataObject> items,
                              @NonNull SectionEvaluator<DataObject> sectionEvaluator,
                              @NonNull Comparator<Section> comparator);  }
@Test public void shouldDelegateBindFirstItemViewHolder() { RecyclerView.ViewHolder viewHolder = mock(RecyclerView.ViewHolder.class); final int position = 1; dynamicRecyclerViewAdapter.onBindViewHolder(viewHolder, position); verify(dynamicRecyclerViewAdapter) .onBindViewHolder(isA(RecyclerView.ViewHolder.class), dataItemCaptor.capture(), positionCaptor.capture()); assertThat(dataItemCaptor.getValue()).isEqualTo(FIRST_ITEM); assertThat(positionCaptor.getValue()).isEqualTo(position); }
@Test public void shouldDelegateBindSecondItemViewHolder() { RecyclerView.ViewHolder viewHolder = mock(RecyclerView.ViewHolder.class); final int position = 3; dynamicRecyclerViewAdapter.onBindViewHolder(viewHolder, position); verify(dynamicRecyclerViewAdapter) .onBindViewHolder(isA(RecyclerView.ViewHolder.class), dataItemCaptor.capture(), positionCaptor.capture()); assertThat(dataItemCaptor.getValue()).isEqualTo(SECOND_ITEM); assertThat(positionCaptor.getValue()).isEqualTo(position); }