/** * @return a {@link DiffUtilComparator} that will be used internally to animate the updates to the * list of items associated to this feature controller. By default, it returns a {@link * DefaultDiffUtilComparator}. * @see DiffUtil */ public DiffUtilComparator createDiffUtilComparator() { return new DefaultDiffUtilComparator<>(); }
@Test public void areContentsTheSame_should_returnFalse_when_Not_equals() throws Exception { //funny but we can't actually mock equals with any mock lib ! //SOF: https://stackoverflow.com/q/3007532/693752 //GIVEN DefaultDiffUtilComparator<String> itemComparatorUnderTest = new DefaultDiffUtilComparator<>(); //WHEN final boolean areContentsTheSame = itemComparatorUnderTest.areContentsTheSame("a", "b"); //THEN assertThat(areContentsTheSame, is(false)); }
@Test public void areItemsTheSame_should_alwaysReturnTrue() throws Exception { //GIVEN DefaultDiffUtilComparator<String> itemComparatorUnderTest = new DefaultDiffUtilComparator<>(); //WHEN final boolean areItemsTheSame = itemComparatorUnderTest.areItemsTheSame("a", "b"); //THEN assertThat(areItemsTheSame, is(true)); }
@Test public void areContentsTheSame_should_returnTrue_when_equals() throws Exception { //funny but we can't actually mock equals with any mock lib ! //SOF: https://stackoverflow.com/q/3007532/693752 //GIVEN DefaultDiffUtilComparator<String> itemComparatorUnderTest = new DefaultDiffUtilComparator<>(); //WHEN final boolean areContentsTheSame = itemComparatorUnderTest.areContentsTheSame("a", "a"); //THEN assertThat(areContentsTheSame, is(true)); } }