@Test public void shouldCompareTwoEntities() throws Exception { when(messageSource.getMessage(INTEGER.getDisplayName(), null, null)) .thenReturn(INTEGER.getDisplayName()); when(messageSource.getMessage(DOUBLE.getDisplayName(), null, null)) .thenReturn(DOUBLE.getDisplayName()); assertTrue(comparator.compare(INTEGER, DOUBLE) > 0); assertTrue(comparator.compare(DOUBLE, INTEGER) < 0); assertTrue(comparator.compare(INTEGER, INTEGER) == 0); assertTrue(comparator.compare(DOUBLE, DOUBLE) == 0); }
@Override public int compare(TypeDto one, TypeDto two) { String oneLabel = messageSource.getMessage(one.getDisplayName(), null, null); String twoLabel = messageSource.getMessage(two.getDisplayName(), null, null); return oneLabel.compareToIgnoreCase(twoLabel); }
TypeDisplayNameComparator implements Comparator<TypeDto>, Serializable { @Override public int compare(TypeDto one, TypeDto two) { String oneLabel = messageSource.getMessage(one.getDisplayName(), null, null); String twoLabel = messageSource.getMessage(two.getDisplayName(), null, null); return oneLabel.compareToIgnoreCase(twoLabel); } }
TypeDisplayNameComparator implements Comparator<TypeDto>, Serializable { @Override public int compare(TypeDto one, TypeDto two) { String oneLabel = messageSource.getMessage(one.getDisplayName(), null, null); String twoLabel = messageSource.getMessage(two.getDisplayName(), null, null); return oneLabel.compareToIgnoreCase(twoLabel); } TypeDisplayNameComparator(MessageSource messageSource); }
TypeDisplayNameComparator implements Comparator<TypeDto>, Serializable { @Override public int compare(TypeDto one, TypeDto two) { String oneLabel = messageSource.getMessage(one.getDisplayName(), null, null); String twoLabel = messageSource.getMessage(two.getDisplayName(), null, null); return oneLabel.compareToIgnoreCase(twoLabel); } TypeDisplayNameComparator(MessageSource messageSource); @Override int compare(TypeDto one, TypeDto two); }
TypeDisplayNameComparator implements Comparator<TypeDto>, Serializable { @Override public int compare(TypeDto one, TypeDto two) { String oneLabel = messageSource.getMessage(one.getDisplayName(), null, null); String twoLabel = messageSource.getMessage(two.getDisplayName(), null, null); return oneLabel.compareToIgnoreCase(twoLabel); } TypeDisplayNameComparator(MessageSource messageSource); @Override int compare(TypeDto one, TypeDto two);  }