ComparatorCompareStrategy implements CompareStrategy<Object> { @SuppressWarnings("unchecked") @Override public boolean equalsObjects(Object value1, Object value2) { return (comparator.compare(value1, value2) == 0); } ComparatorCompareStrategy(Comparator<?> comparator); @SuppressWarnings("unchecked") @Override boolean equalsObjects(Object value1, Object value2);  }
@Test public void testEqualsObjects0001() { Object obj1 = new Object(); Object obj2 = new Object(); ComparatorStub1 comparator = new ComparatorStub1(); comparator.returnValue = 1; ComparatorCompareStrategy strategy = new ComparatorCompareStrategy(comparator); boolean ret = strategy.equalsObjects(obj1, obj2); assertFalse(ret); assertSame(obj1, comparator.obj1); assertSame(obj2, comparator.obj2); }
@Test public void testEqualsObjects0002() { Object obj1 = new Object(); Object obj2 = new Object(); ComparatorStub1 comparator = new ComparatorStub1(); comparator.returnValue = 0; ComparatorCompareStrategy strategy = new ComparatorCompareStrategy(comparator); boolean ret = strategy.equalsObjects(obj1, obj2); assertTrue(ret); assertSame(obj1, comparator.obj1); assertSame(obj2, comparator.obj2); }