### Question:
Role extends DomainObject implements Comparable<Role> { @Override public int compareTo(final Role other) { if (other == null) { return -1; } return new CompareToBuilder().append(name, other.getName()).toComparison(); } Role();  Role(final String name); String getName(); void setName(final String name); @Override String toString(); @Override int compareTo(final Role other);  }### Answer:
@Test public void testCompareTo() { final Role role1 = new Role("role"); final Role role2 = new Role("role"); final Role role3 = new Role("roleNotEqual"); assertThat(role1.compareTo(role2), is(0)); assertThat(role2.compareTo(role1), is(0)); assertThat(role1.compareTo(role3) < 0, is(true)); assertThat(role1.compareTo(null) < 0, is(true)); }