Package net.sf.uadetector.internal.data.domain

Examples of net.sf.uadetector.internal.data.domain.BrowserPattern$Builder


public class IdentifiableComparatorTest {

  @Test
  public void compare_differentIds() {
    final BrowserPattern pattern1 = new BrowserPattern(1, Pattern.compile("[0-9]+", Pattern.MULTILINE), 1);
    final BrowserPattern pattern2 = new BrowserPattern(2, Pattern.compile("[0-9]+", Pattern.CASE_INSENSITIVE), 1);
    assertThat(IdentifiableComparator.INSTANCE.compare(pattern1, pattern2)).isEqualTo(-1);
    assertThat(IdentifiableComparator.INSTANCE.compare(pattern2, pattern1)).isEqualTo(1);
  }
View Full Code Here


    assertThat(IdentifiableComparator.INSTANCE.compare(pattern2, pattern1)).isEqualTo(1);
  }

  @Test
  public void compare_identical() {
    final BrowserPattern pattern1 = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    final BrowserPattern pattern2 = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    assertThat(IdentifiableComparator.INSTANCE.compare(pattern1, pattern2)).isEqualTo(0);
  }
View Full Code Here

    IdentifiableComparator.INSTANCE.compare(null, null);
  }

  @Test
  public void compare_null_2() {
    final BrowserPattern pattern = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    IdentifiableComparator.INSTANCE.compare(null, pattern);
  }
View Full Code Here

    IdentifiableComparator.INSTANCE.compare(null, pattern);
  }

  @Test
  public void compare_null_3() {
    final BrowserPattern pattern = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    IdentifiableComparator.INSTANCE.compare(pattern, null);
  }
View Full Code Here

    IdentifiableComparator.INSTANCE.compare(pattern, null);
  }

  @Test
  public void compare_same() {
    final BrowserPattern pattern = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    assertThat(IdentifiableComparator.INSTANCE.compare(pattern, pattern)).isEqualTo(0);
  }
View Full Code Here

  }

  @Test
  public void equals_different_browserPatterns() {
    final Browser browser = createBrowser(1);
    final BrowserPattern pattern1 = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1);
    final BrowserPattern pattern2 = new BrowserPattern(2, Pattern.compile("[0-9]+"), 1);
    final BrowserPattern pattern3 = new BrowserPattern(3, Pattern.compile("[0-9]+"), 3);
    final BrowserPattern pattern4 = new BrowserPattern(3, Pattern.compile("[0-9]+"), 3);
    final TreeMap<BrowserPattern, Browser> patterns1 = new TreeMap<BrowserPattern, Browser>();
    patterns1.put(pattern1, browser);
    patterns1.put(pattern2, browser);
    final TreeMap<BrowserPattern, Browser> patterns2 = new TreeMap<BrowserPattern, Browser>();
    patterns2.put(pattern1, browser);
View Full Code Here

          b.setOperatingSystem(os);
        }
      } else if (PATTERNS.getName().equals(entry.getKey())) {
        final SortedSet<BrowserPattern> patterns = new TreeSet<BrowserPattern>();
        for (final JsonElement element : entry.getValue().getAsJsonArray()) {
          final BrowserPattern browserPattern = browserPatternDeserializer.findBrowserPattern(element.getAsString());
          if (browserPattern != null) {
            patterns.add(browserPattern);
          }
        }
        b.setPatterns(patterns);
View Full Code Here

      }
    }
    final int id = counter.incrementAndGet();

    // create browser pattern
    BrowserPattern browserPattern = null;
    try {
      browserPattern = new BrowserPattern(id, pattern, id);

      // check hash when option is set
      checkHash(json, hash, browserPattern);

      // add pattern to map
View Full Code Here

  }

  @Nullable
  public BrowserPattern findBrowserPattern(@Nonnull final String hash) {
    Check.notEmpty(hash, "hash");
    final BrowserPattern browserPattern = browserPatterns.get(hash);
    if (browserPattern == null) {
      addWarning("Can not find browser pattern for hash '" + hash + "'.");
    }
    return browserPattern;
  }
View Full Code Here

    final String producer = "producer";
    final BrowserType type = new BrowserType(1, "Browser");
    final SortedSet<OperatingSystemPattern> osPatternSet = new TreeSet<OperatingSystemPattern>();
    final OperatingSystem operatingSystem = new OperatingSystem(1, "n1", "f1", "iu1", osPatternSet, "p1", "pu1", "u1", "i1");
    final SortedSet<BrowserPattern> patterns = new TreeSet<BrowserPattern>();
    patterns.add(new BrowserPattern(1, Pattern.compile("[0-9]"), 1));
    patterns.add(new BrowserPattern(2, Pattern.compile("[a-z]"), 2));
    return new Browser(id, family, family.getName(), patterns, type, operatingSystem, icon, infoUrl, producer, producerUrl, url);
  }
View Full Code Here

TOP

Related Classes of net.sf.uadetector.internal.data.domain.BrowserPattern$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.