ConcatAdapter extends PowerAdapter { @Override public int getItemCount() { return mItemCount; } ConcatAdapter(@NonNull List<? extends PowerAdapter> adapters); @Override int getItemCount(); @Override boolean hasStableIds(); @Override long getItemId(int position); @Override boolean isEnabled(int position); @NonNull @Override Object getItemViewType(int position); @NonNull @Override View newView(@NonNull ViewGroup parent, @NonNull Object viewType); @Override void bindView(
            @NonNull Container container,
            @NonNull View view,
            @NonNull Holder holder,
            @NonNull List<Object> payloads
    );  }
@Test public void parentItemCountIsSumOfChildAdapters() { assertThat(mConcatAdapter.getItemCount()).isEqualTo(12); }
@Test public void itemCountConsistentWhenChildAdaptersAreDependent2() { PowerAdapter adapter = new FakeAdapter(3); PowerAdapter dependentAdapter = new FakeAdapter(1).showOnlyWhile(Condition.adapter(adapter, new Predicate<PowerAdapter>() { @Override public boolean apply(PowerAdapter adapter) { return adapter.getItemCount() > 0; } })); PowerAdapter concatAdapter = concat(dependentAdapter, adapter); VerifyingAdapterObserver verifyingObserver = new VerifyingAdapterObserver(concatAdapter); concatAdapter.registerDataObserver(verifyingObserver); verifyingObserver.assertItemCountConsistent(); }
@Test public void childBindViewContainerItemCountMatchesChildAdapterItemCount() { Container innerContainer = bindViewAndReturnInnerContainer(5, mChildAdapters.get(1), mock(Container.class)); assertThat(innerContainer.getItemCount()).isEqualTo(mChildAdapters.get(1).getItemCount()); }