WordCap implements Comparable<WordCap>, Serializable { @Override public boolean equals(@Nullable Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } WordCap wordCap = (WordCap) o; if (isCapitalized != wordCap.isCapitalized) { return false; } return word.equals(wordCap.word); } WordCap(String word, boolean isCapitalized); String getWord(); boolean isCapitalized(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override int compareTo(WordCap o); @Override String toString();  }
@Test public void testEqualsSameObject() { WordCap wordCap = new WordCap("aWord", false); assertTrue(wordCap.equals(wordCap)); }
@Test public void testEqualsNull() { WordCap wordCap = new WordCap("aWord", false); assertFalse(wordCap.equals(null)); }
@Test public void testEqualsDifferentType() { WordCap wordCap = new WordCap("aWord", false); assertFalse(wordCap.equals("aString")); }
@Test public void testEqualsDifferentWord() { WordCap first = new WordCap("first", false); WordCap second = new WordCap("second", false); assertFalse(first.equals(second)); }
@Test public void testEqualsDifferentCap() { WordCap first = new WordCap("aWord", true); WordCap second = new WordCap("aWord", false); assertFalse(first.equals(second)); }
@Test public void testEquals() { WordCap first = new WordCap("aWord", true); WordCap second = new WordCap("aWord", true); assertTrue(first.equals(second)); }