### Question:
BranchAndRevision implements Comparable<BranchAndRevision> { @Override public int hashCode() { int hashCode = revision.hashCode(); return 31*hashCode + branch.hashCode(); } BranchAndRevision(VersionNode<?, ?, ?> versionNode);  BranchAndRevision(String branch, Revision revision); static BranchAndRevision min(String branch); static BranchAndRevision max(String branch); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(BranchAndRevision other); @Override String toString(); final String branch; final Revision revision; }### Answer:
@Test public void is_equal() { Revision rev = new Revision(); BranchAndRevision bar1 = new BranchAndRevision(DEFAULT_BRANCH, rev); BranchAndRevision bar2 = new BranchAndRevision(DEFAULT_BRANCH, rev); assertThat(bar1).isEqualTo(bar2); assertThat(bar1.hashCode()).isEqualTo(bar2.hashCode()); }
@Test public void not_equal_branch() { BranchAndRevision bar1 = new BranchAndRevision(DEFAULT_BRANCH, new Revision()); BranchAndRevision bar2 = new BranchAndRevision("branch", bar1.revision); assertThat(bar1).isNotEqualTo(bar2); assertThat(bar1.hashCode()).isNotEqualTo(bar2.hashCode()); }
@Test public void not_equal_revision() { BranchAndRevision bar1 = new BranchAndRevision(DEFAULT_BRANCH, new Revision()); BranchAndRevision rev2 = new BranchAndRevision(DEFAULT_BRANCH, new Revision()); assertThat(bar1).isNotEqualTo(rev2); assertThat(bar1.hashCode()).isNotEqualTo(rev2.hashCode()); }