LimitAdapter extends PowerAdapterWrapper { @Override public int getItemCount() { if (getObserverCount() > 0) { return mItemCount; } return getLimitedItemCount(); } LimitAdapter(@NonNull PowerAdapter adapter);  LimitAdapter(@NonNull PowerAdapter adapter, int limit); int getLimit(); void setLimit(int limit); @Override int getItemCount(); @Override long getItemId(int position); @NonNull @Override Object getItemViewType(int position); @Override boolean isEnabled(int position);  }
@Test public void limitedSize() { assertThat(mLimitAdapter.getItemCount()).isEqualTo(5); }
@Test public void removeAll() { configure(5, 8); mFakeAdapter.clear(); assertThat(mLimitAdapter.getItemCount()).isEqualTo(0); verify(mObserver).onItemRangeRemoved(0, 5); verifyNoMoreInteractions(mObserver); }