### Question:
Version implements Comparable<Version> { public Version next(@Nonnull final Version.Element element) { if (element == null) { throw new IllegalArgumentException("null element"); } switch (element) { case MAJOR: if (special == null || this.minor != 0 || this.patch != 0) { return new Version(this.major + 1, 0, 0); } else { return new Version(this.major, 0, 0); } case MINOR: if (special == null || this.patch != 0) { return new Version(this.major, this.minor + 1, 0); } else { return new Version(this.major, this.minor, 0); } case PATCH: if (special == null) { return new Version(this.major, this.minor, this.patch + 1); } else { return new Version(this.major, this.minor, this.patch); } default: throw new IllegalArgumentException("Unknown element <"+element+">"); } } Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch);  Version(@Nonnegative final int major, @Nonnegative final int minor, @Nonnegative final int patch, @Nullable final String separator, @Nullable final String special); static Version parse(@Nonnull final String version); Version next(@Nonnull final Version.Element element); Version toReleaseVersion(); boolean isInDevelopment(); boolean isStable(); boolean isSnapshot(); boolean isCompatible(Version version); @Override int hashCode(); @Override boolean equals(@Nullable final Object object); @Override int compareTo(final Version other); @Override String toString();  }### Answer:
@Test public void next() { final int major = 1; final int minor = 2; final int patch = 3; final Version version = new Version(major, minor, patch); Assert.assertEquals(version.next(Version.Element.MAJOR), new Version(major+1, 0, 0)); Assert.assertEquals(version.next(Version.Element.MINOR), new Version(major, minor+1, 0)); Assert.assertEquals(version.next(Version.Element.PATCH), new Version(major, minor, patch+1)); }
@Test public void nextFromPre() { final Version version1 = new Version(1, 0, 0, "-", "rc1"); Assert.assertEquals(new Version(1, 0, 0), version1.next(Version.Element.MAJOR)); Assert.assertEquals(new Version(1, 0, 0), version1.next(Version.Element.MINOR)); Assert.assertEquals(new Version(1, 0, 0), version1.next(Version.Element.PATCH)); final Version version2 = new Version(1, 1, 0, "-", "rc1"); Assert.assertEquals(new Version(2, 0, 0), version2.next(Version.Element.MAJOR)); Assert.assertEquals(new Version(1, 1, 0), version2.next(Version.Element.MINOR)); Assert.assertEquals(new Version(1, 1, 0), version2.next(Version.Element.PATCH)); final Version version3 = new Version(1, 1, 1, "-", "rc1"); Assert.assertEquals(new Version(2, 0, 0), version3.next(Version.Element.MAJOR)); Assert.assertEquals(new Version(1, 2, 0), version3.next(Version.Element.MINOR)); Assert.assertEquals(new Version(1, 1, 1), version3.next(Version.Element.PATCH)); }
@Test(expected=IllegalArgumentException.class) public void shouldNextWithNullComparisonTypeFail() { final int major = 1; final int minor = 2; final int patch = 3; final Version version = new Version(major, minor, patch); version.next(null); }