### Question:
SimpleCassandraVersion implements Comparable<SimpleCassandraVersion> { public static SimpleCassandraVersion create(String version) { String stripped = SNAPSHOT.matcher(version).replaceFirst(""); Matcher matcher = pattern.matcher(stripped); if (!matcher.matches()) throw new IllegalArgumentException("Invalid version value: " + version); try { int major = Integer.parseInt(matcher.group(1)); int minor = Integer.parseInt(matcher.group(2)); int patch = matcher.group(3) != null ? Integer.parseInt(matcher.group(3)) : 0; return SimpleCassandraVersion.create(major, minor, patch); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid version value: " + version, e); } } private  SimpleCassandraVersion(int major, int minor, int patch); static SimpleCassandraVersion create(String version); static SimpleCassandraVersion create(int major, int minor, int patch); static SimpleCassandraVersion create(ICassandraFactory factory); int compareTo(SimpleCassandraVersion other); @Override boolean equals(Object o); boolean isGreaterThan(SimpleCassandraVersion v2); @Override int hashCode(); @Override String toString(); final int major; final int minor; final int patch; }### Answer:
@Test void testNegativeVersionsFail() { assertThatIllegalArgumentException() .isThrownBy(() -> SimpleCassandraVersion.create(-1, 0, 0)); assertThatIllegalArgumentException() .isThrownBy(() -> SimpleCassandraVersion.create(4, -1, 0)); assertThatIllegalArgumentException() .isThrownBy(() -> SimpleCassandraVersion.create(0, 0, -1)); assertThatIllegalArgumentException() .isThrownBy(() -> SimpleCassandraVersion.create("-3.0.0")); }
@Test void testParseNonZeros() { SimpleCassandraVersion v6 = SimpleCassandraVersion.create("6.14.13"); assertThat(v6.major).isEqualTo(6); assertThat(v6.minor).isEqualTo(14); assertThat(v6.patch).isEqualTo(13); }
@Test void testEqual() { SimpleCassandraVersion v4Alt = SimpleCassandraVersion.create(4, 0, 0); assertThat(v4Alt).isEqualByComparingTo(v4); }
@Test void testSnapshotBuild() { SimpleCassandraVersion alpha = SimpleCassandraVersion.create("4.0-alpha5-SNAPSHOT"); assertThat(alpha.major).isEqualTo(4); assertThat(alpha.minor).isEqualTo(0); assertThat(alpha.patch).isEqualTo(0); }