### Question:
PathComparator implements Comparator<T> { @Override public int compare(T leftBean, T rightBean) { if (leftBean == rightBean) { return 0; } else if (leftBean == null) { return -1; } else if (rightBean == null) { return 1; } else if (leftBean.equals(rightBean)) { return 0; } return comparePathValues(leftBean, rightBean); } PathComparator(Path<V> comparingPath);  PathComparator(Path<V> comparingPath, Function<T,V> accessor); static PathComparator<T, V> pathComparator(Path<V> comparingPath); @Override int compare(T leftBean, T rightBean);  }### Answer:
@Test public void equalReference() { Car car = new Car(); assertEquals(0, comparator.compare(car, car)); }
@Test public void semanticallyEqual() { Car car = new Car(); car.setModel("car"); car.setHorsePower(50); Car similarCar = new Car(); similarCar.setModel("car"); similarCar.setHorsePower(50); assertEquals(0, comparator.compare(car, similarCar)); }
@Test public void leftIsNull() { assertEquals(-1, comparator.compare(null, new Car())); }
@Test public void rightIsNull() { assertEquals(1, comparator.compare(new Car(), null)); }
@Test public void compareOnValue() { Car car = new Car(); car.setHorsePower(50); Car betterCar = new Car(); betterCar.setHorsePower(150); assertEquals(-1, comparator.compare(car, betterCar)); }