Commit { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Commit other = (Commit) obj; return Objects.equals(this.id, other.id); } Commit(Integer id, Committer commiter, Date commitDate);  Commit(Integer id, Committer commiter, Date commitDate, Set<File> files); Integer getId(); Date getCommitDate(); int getNumberOfFiles(); Committer getCommiter(); Set<File> getFiles(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final String HEADER; }
@Test public void testEquals() { final Commit commit1 = new Commit(1, new Committer(1, "Foo", "Bar"), new Date()); final Commit commit2 = new Commit(1, new Committer(2, "Bar", "Foo"), new Date()); assertTrue(commit1.equals(commit1)); assertTrue(commit2.equals(commit2)); assertTrue(commit1.equals(commit2)); assertTrue(commit2.equals(commit1)); }
@Test public void testNotEquals() { final Commit commit1 = new Commit(1, new Committer(1, "Foo", "Bar"), new Date()); final Commit commit2 = new Commit(2, new Committer(1, "Foo", "Bar"), new Date()); assertFalse(commit1.equals(commit2)); assertFalse(commit2.equals(commit1)); }