Package org.apache.lucene.facet.index.categorypolicy

Examples of org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy.shouldAdd()


  @Test
  public void testDefaultOrdinalPolicy() {
    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new DefaultOrdinalPolicy();
    assertFalse("default ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 300; i++) {
      int ordinal = 1 + random.nextInt(Integer.MAX_VALUE - 1);
      assertTrue("default ordinal policy should match " + ordinal,
          ordinalPolicy.shouldAdd(ordinal));
View Full Code Here


    assertFalse("default ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 300; i++) {
      int ordinal = 1 + random.nextInt(Integer.MAX_VALUE - 1);
      assertTrue("default ordinal policy should match " + ordinal,
          ordinalPolicy.shouldAdd(ordinal));
    }
  }

  @Test
  public void testNonTopLevelOrdinalPolicy() throws Exception {
View Full Code Here

          components));
    }
    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new NonTopLevelOrdinalPolicy();
    ordinalPolicy.init(taxonomy);
    assertFalse("top level ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 10; i++) {
      assertFalse("top level ordinal policy should not match "
          + topLevelOrdinals[i],
          ordinalPolicy.shouldAdd(topLevelOrdinals[i]));
View Full Code Here

    assertFalse("top level ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 10; i++) {
      assertFalse("top level ordinal policy should not match "
          + topLevelOrdinals[i],
          ordinalPolicy.shouldAdd(topLevelOrdinals[i]));
    }
    for (int i = 0; i < 300; i++) {
      assertTrue("top level ordinal policy should match "
          + nonTopLevelOrdinals[i],
          ordinalPolicy.shouldAdd(nonTopLevelOrdinals[i]));
View Full Code Here

          ordinalPolicy.shouldAdd(topLevelOrdinals[i]));
    }
    for (int i = 0; i < 300; i++) {
      assertTrue("top level ordinal policy should match "
          + nonTopLevelOrdinals[i],
          ordinalPolicy.shouldAdd(nonTopLevelOrdinals[i]));
    }

    // check illegal ordinal
    assertFalse("Should not add illegal ordinal", ordinalPolicy.shouldAdd(100000));
    taxonomy.close();
View Full Code Here

          + nonTopLevelOrdinals[i],
          ordinalPolicy.shouldAdd(nonTopLevelOrdinals[i]));
    }

    // check illegal ordinal
    assertFalse("Should not add illegal ordinal", ordinalPolicy.shouldAdd(100000));
    taxonomy.close();
    dir.close();
  }

}
View Full Code Here

    }

    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new DefaultOrdinalPolicy();
    assertEquals("ordinal policy does not match default for root"
        + "(seed " + seed + ")", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL), dfip
        .getOrdinalPolicy().shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 30; i++) {
      int ordinal = random.nextInt();
      assertEquals("ordinal policy does not match default for " + ordinal
View Full Code Here

        .shouldAdd(TaxonomyReader.ROOT_ORDINAL), dfip
        .getOrdinalPolicy().shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 30; i++) {
      int ordinal = random.nextInt();
      assertEquals("ordinal policy does not match default for " + ordinal
          + "(seed " + seed + ")", ordinalPolicy.shouldAdd(ordinal),
          dfip.getOrdinalPolicy().shouldAdd(ordinal));
    }
  }

}
View Full Code Here

  @Test
  public void testDefaultOrdinalPolicy() {
    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new DefaultOrdinalPolicy();
    assertFalse("default ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 300; i++) {
      int ordinal = 1 + random.nextInt(Integer.MAX_VALUE - 1);
      assertTrue("default ordinal policy should match " + ordinal,
          ordinalPolicy.shouldAdd(ordinal));
View Full Code Here

    assertFalse("default ordinal policy should not match root", ordinalPolicy
        .shouldAdd(TaxonomyReader.ROOT_ORDINAL));
    for (int i = 0; i < 300; i++) {
      int ordinal = 1 + random.nextInt(Integer.MAX_VALUE - 1);
      assertTrue("default ordinal policy should match " + ordinal,
          ordinalPolicy.shouldAdd(ordinal));
    }
  }

  @Test
  public void testNonTopLevelOrdinalPolicy() throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.