BaseHeaderAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder> { @Override public int getItemCount() { if (mItems.isEmpty()) { return 0; } return mItems.size() + (mHasHeader ? 1 : 0); }  @Override BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType); @Override void onBindViewHolder(BaseRecyclerViewHolder holder, int position); @Override int getItemCount(); @Override @ViewType int getItemViewType(int position); void updateItems(List<I> items); void updateItems(List<I> items, H headerData); void updateItems(List<I> items, H headerData, boolean hasHeader);  }
@Test public void should_return_items_count_0_if_no_item() { adapter.mItems = Collections.emptyList(); int itemCount = adapter.getItemCount(); assertThat(itemCount).isEqualTo(0); }
@Test public void should_return_items_count_plus_one_header_if_any() { adapter.mHasHeader = true; int itemCount = adapter.getItemCount(); assertThat(itemCount).isEqualTo(5); }
@Test public void should_return_items_count_without_header_if_none() { adapter.mHasHeader = false; int itemCount = adapter.getItemCount(); assertThat(itemCount).isEqualTo(4); }