VersionParser { static VersionNumber parseFirstVersionNumber(@Nonnull final String text) { Check.notNull(text, "text"); final Matcher matcher = VERSIONNUMBER_WITH_SUFFIX.matcher(text); String[] split = null; String ext = null; if (matcher.find()) { split = matcher.group(MAJOR_INDEX).split("\\."); ext = matcher.group(EXTENSION_INDEX); } final String extension = ext == null ? VersionNumber.EMPTY_EXTENSION : trimRight(ext); return split == null ? VersionNumber.UNKNOWN : new VersionNumber(Arrays.asList(split), extension); } private  VersionParser(); static VersionNumber parseLastVersionNumber(@Nonnull final String text); static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent); static VersionNumber parseVersion(@Nonnull final String version);  }
@Test public void parseFirstVersionNumber_emptyString() { final String userAgent = ""; final VersionNumber v = VersionParser.parseFirstVersionNumber(userAgent); assertThat(v).isEqualTo(VersionNumber.UNKNOWN); }
@Test public void parseFirstVersionNumber_MOZILLA() { final String userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http: final String version = "5.0"; final VersionNumber v = VersionParser.parseFirstVersionNumber(userAgent); assertThat(v.toVersionString()).isEqualTo(version); }
@Test(expected = IllegalNullArgumentException.class) public void parseFirstVersionNumber_null() { VersionParser.parseFirstVersionNumber(null); }