VersionParser { static VersionNumber identifyBadaVersion(final String userAgent) { VersionNumber version = VersionNumber.UNKNOWN; final Pattern pattern = Pattern.compile("Bada/((\\d+)((\\.\\d+)+)?)"); final Matcher m = pattern.matcher(userAgent); if (m.find()) { version = parseFirstVersionNumber(m.group(MAJOR_INDEX)); } return version; } 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 identifyBadaVersion() { final String bada10 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S7230E/S723EXXJJ3; U; Bada/1.0; nl-nl) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WQVGA SMM-MMS/1.2.0 OPN-B"; assertThat(VersionParser.identifyBadaVersion(bada10).toVersionString()).isEqualTo("1.0"); final String bada12 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/S8500JHKC1; U; Bada/1.2; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.2 Mobile WVGA SMM-MMS/1.2.0 OPN-B"; assertThat(VersionParser.identifyBadaVersion(bada12).toVersionString()).isEqualTo("1.2"); final String bada20 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S5380K/S5380KDDKK6; U; Bada/2.0; en-us) AppleWebKit/534.20 (KHTML"; assertThat(VersionParser.identifyBadaVersion(bada20).toVersionString()).isEqualTo("2.0"); }