### Question:
Version implements Comparable<Version> { @Override public int compareTo(Version version) { if (major < version.getMajor()) return -1; else if (major > version.getMajor()) return 1; else if ((minor<0?0:minor) < (version.getMinor()<0?0:version.getMinor())) return -1; else if ((minor<0?0:minor) > (version.getMinor()<0?0:version.getMinor())) return 1; else if ((patch<0?0:patch) < (version.getPatch()<0?0:version.getPatch())) return -1; else if ((patch<0?0:patch) > (version.getPatch()<0?0:version.getPatch())) return 1; else if (!qualifier.equals(version.getQualifier())) return qualifier.compareTo(version.getQualifier()); else return (build<0?0:build) - (version.getBuild()<0?0:version.getBuild()); } Version(String versionStr);  Version(int major, int minor, int patch, String qualifier, int build);  Version(int major, int minor, int patch);  Version(int major, int minor);  Version(int major); int getMajor(); int getMinor(); int getPatch(); String getQualifier(); int getBuild(); boolean isCompatible(Version version); @Override int compareTo(Version version); @Override String toString();  }### Answer:
@Test public void shouldCompareVersionCorrectly() { assertTrue(new Version("1").compareTo(new Version("1")) == 0); assertTrue(new Version("1.0.1").compareTo(new Version("1.0.1")) == 0); assertTrue(new Version("1").compareTo(new Version("1.0")) == 0); assertTrue(new Version("1.2-build").compareTo(new Version("1.2.0-build-0")) == 0); assertTrue(new Version("1").compareTo(new Version("2")) < 0); assertTrue(new Version("1.9.1").compareTo(new Version("1.10.1")) < 0); assertTrue(new Version("1.9.1-beta-1").compareTo(new Version("1.9.1-beta-4")) < 0); assertTrue(new Version("1.9.1-alpha-1").compareTo(new Version("1.9.1-beta-1")) < 0); assertTrue(new Version("1.9.1-alpha").compareTo(new Version("1.9.1-alpha-1")) < 0); assertTrue(new Version("1.9-alpha").compareTo(new Version("1.9.1-alpha")) < 0); }