Shuffle extends FrameLayout { void moveFirstCardToStack() { CardDraggableView firstCard = draggableViews.removeFirst(); draggableViews.addLast(firstCard); removeAllViews(); int numberOfCards = shuffleSettings.getNumberOfDisplayedCards(); for (int i = numberOfCards - 1; i >= 0; i--) { addView(draggableViews.get(i)); } adapterPosition++; updateAdapter(); dispatchAdapterPositionToListeners(); checkScrollFinished(); } 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 testMoveFirstCardToStack() throws Exception { final List<View> viewsList = new ArrayList<>(); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { viewsList.add((View) invocation.getArguments()[0]); return null; } }).when(shuffle).addView(any(View.class)); shuffle.adapterPosition = 4; given(shuffleSettings.getNumberOfDisplayedCards()).willReturn(3); CardDraggableView draggableView1 = mockDraggableView(); CardDraggableView draggableView2 = mockDraggableView(); CardDraggableView draggableView3 = mockDraggableView(); shuffle.draggableViews.addAll(Arrays.asList(draggableView1, draggableView2, draggableView3)); shuffle.moveFirstCardToStack(); assertThat(shuffle.draggableViews.get(0)).isEqualTo(draggableView2); assertThat(shuffle.draggableViews.get(1)).isEqualTo(draggableView3); assertThat(shuffle.draggableViews.get(2)).isEqualTo(draggableView1); verify(shuffle).removeAllViews(); assertThat(viewsList.get(0)).isEqualTo(draggableView1); assertThat(viewsList.get(1)).isEqualTo(draggableView3); assertThat(viewsList.get(2)).isEqualTo(draggableView2); assertThat(shuffle.adapterPosition).isEqualTo(5); }