### Question:
WmsVersion implements Comparable<WmsVersion> { @Override public int compareTo(WmsVersion o) { if (o == null) { throw new NullPointerException("Version to compare to must not be null"); } if (this.major != o.major) { return this.major < o.major ? -1 : 1; } if (this.minor != o.minor) { return this.minor < o.minor ? -1 : 1; } if (this.build != o.build) { return this.build < o.build ? -1 : 1; } return 0; } WmsVersion(String version);  WmsVersion(int major, int minor, int build); int getMajor(); int getMinor(); int getBuild(); @Override int compareTo(WmsVersion o); @Override String toString(); String toVersionString(); static void validateVersion(String version);  }### Answer:
@Test public void testCompareTo() { WmsVersion version111 = new WmsVersion("1.1.1"); WmsVersion version112 = new WmsVersion("1.1.2"); WmsVersion version110 = new WmsVersion("1.1"); WmsVersion version130 = new WmsVersion("1.3"); WmsVersion version200 = new WmsVersion("2.0"); assertThat(version111.compareTo(version112), is(-1)); assertThat(version112.compareTo(version111), is(1)); assertThat(version111.compareTo(version130), is(-1)); assertThat(version130.compareTo(version111), is(1)); assertThat(version130.compareTo(version130), is(0)); assertThat(version110.compareTo(version111), is(-1)); assertThat(version200.compareTo(version111), is(1)); assertThat(version130.compareTo(version200), is(-1)); }
@Test(expected = NullPointerException.class) public void testCompareToNull() { WmsVersion version = new WmsVersion("1.1.1"); version.compareTo(null); }