BaseDocumentation implements Comparable<BaseDocumentation> { @Override public int compareTo(BaseDocumentation o) { return this.id.compareTo(o.id); } BaseDocumentation();  BaseDocumentation(String id, Description description); boolean isDocumented(); boolean hasText(); String getId(); Description getDescription(); void setId(String id); void setDescription(Description description); String summarize(int length); String joinDescriptionText(String between); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(BaseDocumentation o);  }
@Test public void testCompareTo() { BaseDocumentation abc = new BaseDocumentation("abc",null); BaseDocumentation def = new BaseDocumentation("def",null); assertEquals(abc.getId().compareTo(def.getId()),abc.compareTo(def)); assertEquals(def.getId().compareTo(abc.getId()),def.compareTo(abc)); BaseDocumentation abcAlso = new BaseDocumentation("abc",new Description("duh")); assertEquals(0, abc.compareTo(abcAlso)); assertEquals(0, abcAlso.compareTo(abc)); }
@Test public void testCompareToThrowsNullPointerExceptionBecauseIdIsNotSet() { BaseDocumentation bd = new BaseDocumentation("abc",null); assertThrows(NullPointerException.class, () -> { bd.compareTo(new BaseDocumentation()); }); }