### Question:
PropertyModelObjectComparator implements Comparator<Object> { public int compare(Object o1, Object o2) { PropertyModel<Object> model1 = new PropertyModel<Object>(o1, sortProperty); PropertyModel<Object> model2 = new PropertyModel<Object>(o2, sortProperty); int compare = ((Comparable<Object>)model1.getObject()).compareTo(model2.getObject()); return ascending ? compare : compare * -1; } PropertyModelObjectComparator(boolean ascending, String sortProperty); int compare(Object o1, Object o2);  }### Answer:
@Test public void shouldReturnNegativeIfObject1IsConsideredMoreThanObject2AndSortOrderIsDescending() { PropertyModelObjectComparator ascComparator = new PropertyModelObjectComparator(false, "name"); assertEquals(-1, ascComparator.compare(new PropertyModelObject("ben2"), new PropertyModelObject("ben1"))); }
@Test public void shouldReturnZeroIfObjectsAreEqual() { PropertyModelObjectComparator ascComparator = new PropertyModelObjectComparator(true, "name"); assertEquals(0, ascComparator.compare(new PropertyModelObject("ben"), new PropertyModelObject("ben"))); PropertyModelObjectComparator descComparator = new PropertyModelObjectComparator(false, "name"); assertEquals(0, descComparator.compare(new PropertyModelObject("ben"), new PropertyModelObject("ben"))); }
@Test public void shouldReturnNegativeIfObject1IsConsideredLessThanObject2AndSortOrderIsAscending() { PropertyModelObjectComparator ascComparator = new PropertyModelObjectComparator(true, "name"); assertEquals(-1, ascComparator.compare(new PropertyModelObject("ben1"), new PropertyModelObject("ben2"))); }
@Test public void shouldReturnPositiveIfObject1IsConsideredLessThanObject2AndSortOrderIsDescending() { PropertyModelObjectComparator ascComparator = new PropertyModelObjectComparator(false, "name"); assertEquals(1, ascComparator.compare(new PropertyModelObject("ben1"), new PropertyModelObject("ben2"))); }
@Test public void shouldReturnPositiveIfObject1IsConsideredMoreThanObject2AndSortOrderIsAscending() { PropertyModelObjectComparator ascComparator = new PropertyModelObjectComparator(true, "name"); assertEquals(1, ascComparator.compare(new PropertyModelObject("ben2"), new PropertyModelObject("ben1"))); }