### Question:
SchemaVersionRange { public static SchemaVersionRange parse(String versionStr) { versionStr = StringUtils.stripToNull(versionStr); Validate.notNull(versionStr, "Version string is blank"); if (isVersionStr(versionStr)) { return parseVersionStr(versionStr); } else if (isVersionRangeStr(versionStr)) { return parseVersionRangeStr(versionStr); } else { throw new IllegalArgumentException(String.format("Invalid version string %s", versionStr)); } } SchemaVersionRange(int earliest, int latest); boolean before(int version); boolean contains(int version); boolean after(int version); @Override String toString(); static SchemaVersionRange with(int earliest, int latest); static SchemaVersionRange parse(String versionStr); final int earliest; final int latest; }### Answer:
@Test public void testRangeIsParsedFromVersionString() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" 1 "); Assert.assertNotNull(range); Assert.assertEquals(1, range.earliest); Assert.assertEquals(1, range.latest); }
@Test(expected=Exception.class) public void testRangeIsNotParsedFromInvalidVersionString1() throws Exception { SchemaVersionRange.parse(" "); }
@Test(expected=Exception.class) public void testRangeIsNotParsedFromInvalidVersionString2() throws Exception { SchemaVersionRange.parse(""); }
@Test(expected=Exception.class) public void testRangeIsNotParsedFromInvalidVersionString3() throws Exception { SchemaVersionRange.parse("a"); }
@Test public void testRangeIsParsedFromVersionRangeString1() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" [,] "); Assert.assertNotNull(range); Assert.assertEquals(0, range.earliest); Assert.assertEquals(Integer.MAX_VALUE, range.latest); }
@Test public void testRangeIsParsedFromVersionRangeString2() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" [ , ] "); Assert.assertNotNull(range); Assert.assertEquals(0, range.earliest); Assert.assertEquals(Integer.MAX_VALUE, range.latest); }
@Test public void testRangeIsParsedFromVersionRangeString3() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" [ 1 , ] "); Assert.assertNotNull(range); Assert.assertEquals(1, range.earliest); Assert.assertEquals(Integer.MAX_VALUE, range.latest); }
@Test public void testRangeIsParsedFromVersionRangeString4() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" [ , 1 ] "); Assert.assertNotNull(range); Assert.assertEquals(0, range.earliest); Assert.assertEquals(1, range.latest); }
@Test public void testRangeIsParsedFromVersionRangeString5() throws Exception { SchemaVersionRange range = SchemaVersionRange.parse(" [ 1 , 1 ] "); Assert.assertNotNull(range); Assert.assertEquals(1, range.earliest); Assert.assertEquals(1, range.latest); }