FrontendVersion implements Serializable, Comparable<FrontendVersion> { public boolean isNewerThan(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 newerVersionIsCalculatedCorrectly() { FrontendVersion test = new FrontendVersion("2.2.2"); assertTrue("Should be newer due to revision", test.isNewerThan(new FrontendVersion("2.2.1"))); assertTrue("Should be newer due to minor", test.isNewerThan(new FrontendVersion("2.1.2"))); assertTrue("Should be newer due to major", test.isNewerThan(new FrontendVersion("1.2.2"))); assertTrue("Should be newer as target has buildIdentifier", test.isNewerThan(new FrontendVersion("2.2.2-alpha1"))); assertFalse("Should be older due to major", test.isNewerThan(new FrontendVersion("3.2.2"))); assertFalse("Should be older due to minor", test.isNewerThan(new FrontendVersion("2.3.2"))); }
@Test public void newerVersionByBuildIdentifier() { FrontendVersion test = new FrontendVersion("2.0.0-alpha2"); assertTrue("alpha2 should be newer than alpha1", test.isNewerThan(new FrontendVersion("2.0.0-alpha1"))); assertFalse("alpha2 should be older than 2.0.0", test.isNewerThan(new FrontendVersion("2.0.0"))); assertFalse("alpha2 should be older than beta1", test.isNewerThan(new FrontendVersion("2.0.0-beta1"))); assertFalse("alpha2 should be older than RC1", test.isNewerThan(new FrontendVersion("2.0.0-RC1"))); test = new FrontendVersion("2.0.0"); assertTrue("2.0.0 should be newer than alpha1", test.isNewerThan(new FrontendVersion("2.0.0-alpha1"))); assertTrue("2.0.0 should be older than beta1", test.isNewerThan(new FrontendVersion("2.0.0-beta1"))); assertTrue("2.0.0 should be older than RC1", test.isNewerThan(new FrontendVersion("2.0.0-RC1"))); }