FrontendVersion implements Serializable, Comparable<FrontendVersion> { public boolean isOlderThan(FrontendVersion otherVersion) { return compareTo(otherVersion) < 0; } FrontendVersion(int major, int minor);  FrontendVersion(int major, int minor, int revision);  FrontendVersion(int major, int minor, int revision, String build);  FrontendVersion(String version); String getFullVersion(); int getMajorVersion(); int getMinorVersion(); int getRevision(); String getBuildIdentifier(); boolean isOlderThan(FrontendVersion otherVersion); boolean isNewerThan(FrontendVersion otherVersion); boolean isEqualTo(FrontendVersion otherVersion); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(FrontendVersion other);  }
@Test public void olderVersionIsCalculatedCorrectly() { FrontendVersion test = new FrontendVersion("2.2.0"); assertTrue("Should be older due to revision", test.isOlderThan(new FrontendVersion("2.2.1"))); assertTrue("Should be older due to minor", test.isOlderThan(new FrontendVersion("2.3.0"))); assertTrue("Should be older due to major", test.isOlderThan(new FrontendVersion("3.2.0"))); assertFalse("Should be newer as target has buildIdentifier", test.isOlderThan(new FrontendVersion("2.2.0-alpha1"))); assertFalse("Should be newer due to major", test.isOlderThan(new FrontendVersion("1.2.0"))); assertFalse("Should be newer due to minor", test.isOlderThan(new FrontendVersion("2.1.0"))); assertFalse("Should be newer due to minor", test.isOlderThan(new FrontendVersion("2.1.2"))); assertFalse("Should be newer due to minor", test.isOlderThan(new FrontendVersion("1.5.2"))); assertFalse("Should be newer by major even with buildIdentifier", test.isOlderThan(new FrontendVersion("1.2.0-alpha1"))); }
@Test public void olderVersionByBuildIdentifier() { FrontendVersion test = new FrontendVersion("2.0.0-RC1"); assertTrue("2.0.0 should be newer that RC1", test.isOlderThan(new FrontendVersion("2.0.0"))); assertTrue("RC2 should be newer that RC1", test.isOlderThan(new FrontendVersion("2.0.0-RC2"))); assertFalse("beta5 should be older than RC1", test.isOlderThan(new FrontendVersion("2.0.0-beta5"))); assertFalse("alpha4 should be older than RC1", test.isOlderThan(new FrontendVersion("2.0.0-alpha4"))); test = new FrontendVersion("2.0.0"); assertFalse("RC2 should be older that 2.0.0", test.isOlderThan(new FrontendVersion("2.0.0-RC2"))); assertFalse("beta5 should be older than 2.0.0", test.isOlderThan(new FrontendVersion("2.0.0-beta5"))); assertFalse("alpha4 should be older than 2.0.0", test.isOlderThan(new FrontendVersion("2.0.0-alpha4"))); }