DiffUtilCallback extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { final Object oldItem = getOldItem(oldItemPosition); final Object newItem = getNewItem(newItemPosition); if (oldItem == null) { return newItem == null; } else { return newItem != null && diffCallback.areItemsTheSame(oldItem, newItem); } } DiffUtilCallback(List<?> oldItems, List<?> newItems, @NonNull DiffCallback diffCallback); @Override int getOldListSize(); @Override int getNewListSize(); @Override boolean areItemsTheSame(int oldItemPosition, int newItemPosition); @Override boolean areContentsTheSame(int oldItemPosition, int newItemPosition); @Override int hashCode(); @Override boolean equals(Object o);  }
@Test public void shouldDelegateAreItemsTheSame() throws Exception { diffUtilCallback.areItemsTheSame(2, 2); Mockito.verify(diffCallback).areItemsTheSame(Mockito.eq("3"), Mockito.eq("4")); }