@Test public void examineAsBrowser_noMatchingSubGroupToGatherVersionNumber() { final Set<Browser> browsers = new HashSet<Browser>(); final Map<Integer, SortedSet<BrowserPattern>> browserPatterns = Maps.newHashMap(); final Map<Integer, BrowserType> browserTypes = Maps.newHashMap(); final SortedMap<BrowserPattern, Browser> patternToBrowserMap = new TreeMap<BrowserPattern, Browser>(); final Set<BrowserOperatingSystemMapping> browserToOperatingSystemMappings = Sets.newHashSet(); final Set<OperatingSystem> operatingSystems = new HashSet<OperatingSystem>(); final Map<Integer, SortedSet<OperatingSystemPattern>> operatingSystemPatterns = Maps.newHashMap(); final SortedMap<OperatingSystemPattern, OperatingSystem> patternToOperatingSystemMap = new TreeMap<OperatingSystemPattern, OperatingSystem>(); final List<Robot> robots = new ArrayList<Robot>(); final Set<Device> devices = new HashSet<Device>(0); final Map<Integer, SortedSet<DevicePattern>> devicePatterns = new HashMap<Integer, SortedSet<DevicePattern>>(0); final SortedMap<DevicePattern, Device> patternToDeviceMap = new TreeMap<DevicePattern, Device>(); final String version = "test-version"; final TreeSet<BrowserPattern> browserPatternSet = Sets.newTreeSet(); final Pattern pattern = RegularExpressionConverter.convertPerlRegexToPattern("/^Eudora?/si "); final BrowserPattern browserPattern = new BrowserPattern(465, pattern, 439); browserPatternSet.add(browserPattern); browserPatterns.put(1, browserPatternSet); final BrowserType browserType = new BrowserType(2, "Browser"); browserTypes.put(browserType.getId(), browserType); final Browser browser = new Browser(465, UserAgentFamily.EUDORA, "Eudora", new TreeSet<BrowserPattern>(), browserType, null, "eudora.png", "/list-of-ua/browser-detail?browser=Eudora", "Qualcomm Incorporated.", "http: "http: browsers.add(browser); patternToBrowserMap.put(browserPattern, browser); final Data data = new Data(browsers, browserPatterns, browserTypes, patternToBrowserMap, browserToOperatingSystemMappings, operatingSystems, operatingSystemPatterns, patternToOperatingSystemMap, robots, devices, devicePatterns, patternToDeviceMap, version); final UserAgentStringParser parser = new UserAgentStringParserImpl<DataStore>(new DataStore() { @Override public Charset getCharset() { return DataStore.DEFAULT_CHARSET; } @Override public Data getData() { return data; } @Override public DataReader getDataReader() { return null; } @Override public URL getDataUrl() { return null; } @Override public URL getVersionUrl() { return null; } }); final ReadableUserAgent ua1 = parser.parse("Eudora"); assertThat(ua1.getFamily()).isEqualTo(UserAgentFamily.EUDORA); assertThat(ua1.getVersionNumber().toVersionString()).isEqualTo(""); assertThat(ua1.getDeviceCategory()).isEqualTo(DeviceCategory.EMPTY); final ReadableUserAgent ua2 = parser.parse("Eudora/1.0"); assertThat(ua2.getFamily()).isEqualTo(UserAgentFamily.EUDORA); assertThat(ua2.getVersionNumber().toVersionString()).isEqualTo(""); assertThat(ua2.getDeviceCategory()).isEqualTo(DeviceCategory.EMPTY); }
@Override public UserAgent parse(final String userAgent) { final UserAgent.Builder builder = new UserAgent.Builder(userAgent); final Data data = getDataStore().getData(); if (!examineAsRobot(builder, data)) { examineAsBrowser(builder, data); examineOperatingSystem(builder, data); } examineDeviceCategory(builder, data); return builder.build(); }
AbstractUserAgentStringParser implements UserAgentStringParser { @Override public UserAgent parse(final String userAgent) { final UserAgent.Builder builder = new UserAgent.Builder(userAgent); final Data data = getDataStore().getData(); if (!examineAsRobot(builder, data)) { examineAsBrowser(builder, data); examineOperatingSystem(builder, data); } examineDeviceCategory(builder, data); return builder.build(); } }
AbstractUserAgentStringParser implements UserAgentStringParser { @Override public UserAgent parse(final String userAgent) { final UserAgent.Builder builder = new UserAgent.Builder(userAgent); final Data data = getDataStore().getData(); if (!examineAsRobot(builder, data)) { examineAsBrowser(builder, data); examineOperatingSystem(builder, data); } examineDeviceCategory(builder, data); return builder.build(); }  }
AbstractUserAgentStringParser implements UserAgentStringParser { @Override public UserAgent parse(final String userAgent) { final UserAgent.Builder builder = new UserAgent.Builder(userAgent); final Data data = getDataStore().getData(); if (!examineAsRobot(builder, data)) { examineAsBrowser(builder, data); examineOperatingSystem(builder, data); } examineDeviceCategory(builder, data); return builder.build(); }  @Override String getDataVersion(); @Override UserAgent parse(final String userAgent); @Override void shutdown(); }
AbstractUserAgentStringParser implements UserAgentStringParser { @Override public UserAgent parse(final String userAgent) { final UserAgent.Builder builder = new UserAgent.Builder(userAgent); final Data data = getDataStore().getData(); if (!examineAsRobot(builder, data)) { examineAsBrowser(builder, data); examineOperatingSystem(builder, data); } examineDeviceCategory(builder, data); return builder.build(); }  @Override String getDataVersion(); @Override UserAgent parse(final String userAgent); @Override void shutdown();  }