Shuffle extends FrameLayout { public void setShuffleAdapter(@Nullable Adapter shuffleAdapter) { this.shuffleAdapter = shuffleAdapter; if (shuffleAdapter != null) { shuffleAdapter.shuffleWeakReference = new WeakReference<>(this); } notifyDataSetChanged(); } Shuffle(Context context);  Shuffle(Context context, AttributeSet attrs);  Shuffle(Context context, AttributeSet attrs, int defStyleAttr); ShuffleSettings getShuffleSettings(); @Nullable Adapter getShuffleAdapter(); void setShuffleAdapter(@Nullable Adapter shuffleAdapter); void addListener(Listener listener); void removeListener(Listener listener); ShuffleViewAnimator getViewAnimator(); void setViewAnimator(ShuffleViewAnimator viewAnimator); void swipeRight(int duration); void swipeLeft(int duration); int getCurrentAdapterPosition(); CardDraggableView getDraggableView(int position); CardDraggableView getLastDraggableView(); CardDraggableView getFirstDraggableView(); void enable(boolean enable); void restartShuffling(); void revert(int duration);  }
@Test public void testUpdateAdapter_firstTime() throws Exception { given(shuffleSettings.getNumberOfDisplayedCards()).willReturn(3); shuffle.adapterPosition = 0; CardDraggableView draggableView1 = mockDraggableView(); CardDraggableView draggableView2 = mockDraggableView(); CardDraggableView draggableView3 = mockDraggableView(); shuffle.draggableViews.addAll(Arrays.asList(draggableView1, draggableView2, draggableView3)); Shuffle.Adapter shuffleAdapter = mock(Shuffle.Adapter.class); Shuffle.ViewHolder mockHolder = mock(Shuffle.ViewHolder.class); { given(shuffleAdapter.getItemCount()).willReturn(10); given(shuffleAdapter.getItemViewType(anyInt())).willReturn(1); mockHolder.itemView = mock(View.class); given(shuffleAdapter.onCreateViewHolder(any(ViewGroup.class), anyInt())).willReturn(mockHolder); } shuffle.setShuffleAdapter(shuffleAdapter); verify(shuffleAdapter).onCreateViewHolder(eq(draggableView1), anyInt()); verify(shuffleAdapter).onCreateViewHolder(eq(draggableView2), anyInt()); verify(shuffleAdapter).onCreateViewHolder(eq(draggableView3), anyInt()); verify(draggableView1.getContent()).removeAllViews(); verify(draggableView1.getContent()).addView(eq(mockHolder.itemView)); assertThat(mockHolder.position).isEqualTo(2); verify(shuffleAdapter).onBindViewHolder(eq(mockHolder), eq(0)); verify(shuffleAdapter).onBindViewHolder(eq(mockHolder), eq(1)); }