MultiChoiceAdapter extends RecyclerView.Adapter<VH> implements MultiChoiceToolbar.Listener { public boolean deselect(int position) { if (mItemList.containsKey(position) && mItemList.get(position) == State.ACTIVE) { perform(Action.DESELECT, position, true, true); return true; } return false; }  void setActive(@NonNull View view, boolean state); void deselectAll(); void selectAll(); boolean select(int position); boolean deselect(int position); void setSingleClickMode(boolean set); int getSelectedItemCount(); List<Integer> getSelectedItemList(); void setMultiChoiceSelectionListener(Listener listener); void setMultiChoiceToolbar(MultiChoiceToolbar multiChoiceToolbar); boolean isInSingleClickMode(); void onSaveInstanceState(@Nullable Bundle savedInstanceState); void onRestoreInstanceState(Bundle savedInstanceState); @Override void onClearButtonPressed(); @Override void onAttachedToRecyclerView(RecyclerView recyclerView); @Override void onBindViewHolder(final VH holder, final int position);  }
@Test public void givenItemActiveWhenDeselectThenDeselect() throws Exception { when(mMockItemList.containsKey(mTestPosition)).thenReturn(true); when(mMockItemList.get(mTestPosition)).thenReturn(MultiChoiceAdapter.State.ACTIVE); mMultiChoiceAdapter.deselect(mTestPosition); verify(mMockItemList, times(1)).put(mTestPosition, MultiChoiceAdapter.State.INACTIVE); }
@Test public void givenItemInactiveWhenDeselectThenNothing() throws Exception { when(mMockItemList.containsKey(mTestPosition)).thenReturn(true); when(mMockItemList.get(mTestPosition)).thenReturn(MultiChoiceAdapter.State.INACTIVE); mMultiChoiceAdapter.deselect(mTestPosition); verify(mMockItemList, times(0)).put(anyInt(), any(MultiChoiceAdapter.State.class)); }