DebianVersion implements Comparable<DebianVersion> { @Override public int compareTo(final DebianVersion o) { if (this.epoch < o.epoch) { return -1; } else if (this.epoch > o.epoch) { return 1; } else { int uv = compareDebianVersion(this.upstreamVersion, o.upstreamVersion); if (uv != 0) { return uv; } return compareDebianVersion(this.debianRevision, o.debianRevision); } } DebianVersion(final String version); int getEpoch(); String getDebianRevision(); String getUpstreamVersion(); @Override String toString(); @Override int compareTo(final DebianVersion o); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void testCompareVersionIsSimilar() { assertThat(new DebianVersion(LOWER_EPOCH_UPSTREAM_DEBIAN).compareTo(new DebianVersion(LOWER_EPOCH_UPSTREAM_DEBIAN)), is(0)); assertThat(new DebianVersion(UPSTREAM_DEBIAN).compareTo(new DebianVersion(UPSTREAM_DEBIAN)), is(0)); assertThat(new DebianVersion(UPSTREAM_DEBIAN_TILDE).compareTo(new DebianVersion(UPSTREAM_DEBIAN_TILDE)), is(0)); assertThat(new DebianVersion(UPSTREAM).compareTo(new DebianVersion(UPSTREAM)), is(0)); }
@Test public void testCompareLowerEpochVersion() { assertThat( new DebianVersion(HIGHER_EPOCH_UPSTREAM_DEBIAN).compareTo(new DebianVersion(LOWER_EPOCH_UPSTREAM_DEBIAN)), is(1)); }
@Test public void testCompareHigherEpochVersion() { assertThat( new DebianVersion(LOWER_EPOCH_UPSTREAM_DEBIAN).compareTo(new DebianVersion(HIGHER_EPOCH_UPSTREAM_DEBIAN)), is(-1)); }