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

Examples of org.apache.lucene.facet.index.categorypolicy.PathPolicy


  @Test
  public void testDefaultPathPolicy() {
    // check path policy
    CategoryPath cp = new CategoryPath();
    PathPolicy pathPolicy = new DefaultPathPolicy();
    assertFalse("default path policy should not accept root",
        pathPolicy.shouldAdd(cp));
    for (int i = 0; i < 300; i++) {
      int nComponents = 1 + random.nextInt(10);
      String[] components = new String[nComponents];
      for (int j = 0; j < components.length; j++) {
        components[j] = (Integer.valueOf(random.nextInt(30))).toString();
      }
      cp = new CategoryPath(components);
      assertTrue("default path policy should accept "
          + cp.toString('/'),
          pathPolicy.shouldAdd(cp));
    }
  }
View Full Code Here


      }
      nonTopLevelPaths[i] = new CategoryPath(components);
      taxonomy.addCategory(nonTopLevelPaths[i]);
    }
    // check ordinal policy
    PathPolicy pathPolicy = new NonTopLevelPathPolicy();
    assertFalse("top level path policy should not match root",
        pathPolicy.shouldAdd(new CategoryPath()));
    for (int i = 0; i < 10; i++) {
      assertFalse("top level path policy should not match "
          + topLevelPaths[i],
          pathPolicy.shouldAdd(topLevelPaths[i]));
    }
    for (int i = 0; i < 300; i++) {
      assertTrue("top level path policy should match "
          + nonTopLevelPaths[i],
          pathPolicy.shouldAdd(nonTopLevelPaths[i]));
    }
    taxonomy.close();
    dir.close();
  }
View Full Code Here

  public void testCategoryPolicies() {
    FacetIndexingParams dfip = new DefaultFacetIndexingParams();
    long seed = System.currentTimeMillis();
    // check path policy
    CategoryPath cp = new CategoryPath();
    PathPolicy pathPolicy = new DefaultPathPolicy();
    assertEquals("path policy does not match default for root" + "(seed "
        + seed + ")", pathPolicy.shouldAdd(cp), dfip.getPathPolicy()
        .shouldAdd(cp));
    for (int i = 0; i < 30; i++) {
      int nComponents = random.nextInt(10);
      String[] components = new String[nComponents];
      for (int j = 0; j < components.length; j++) {
        components[j] = (Integer.valueOf(random.nextInt(30))).toString();
      }
      cp = new CategoryPath(components);
      assertEquals("path policy does not match default for "
          + cp.toString('/') + "(seed " + seed + ")", pathPolicy
          .shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
    }

    // check ordinal policy
    OrdinalPolicy ordinalPolicy = new DefaultOrdinalPolicy();
View Full Code Here

  @Test
  public void testDefaultPathPolicy() {
    // check path policy
    CategoryPath cp = new CategoryPath();
    PathPolicy pathPolicy = new DefaultPathPolicy();
    assertFalse("default path policy should not accept root",
        pathPolicy.shouldAdd(cp));
    for (int i = 0; i < 300; i++) {
      int nComponents = 1 + random.nextInt(10);
      String[] components = new String[nComponents];
      for (int j = 0; j < components.length; j++) {
        components[j] = (Integer.valueOf(random.nextInt(30))).toString();
      }
      cp = new CategoryPath(components);
      assertTrue("default path policy should accept "
          + cp.toString('/'),
          pathPolicy.shouldAdd(cp));
    }
  }
View Full Code Here

      }
      nonTopLevelPaths[i] = new CategoryPath(components);
      taxonomy.addCategory(nonTopLevelPaths[i]);
    }
    // check ordinal policy
    PathPolicy pathPolicy = new NonTopLevelPathPolicy();
    assertFalse("top level path policy should not match root",
        pathPolicy.shouldAdd(new CategoryPath()));
    for (int i = 0; i < 10; i++) {
      assertFalse("top level path policy should not match "
          + topLevelPaths[i],
          pathPolicy.shouldAdd(topLevelPaths[i]));
    }
    for (int i = 0; i < 300; i++) {
      assertTrue("top level path policy should match "
          + nonTopLevelPaths[i],
          pathPolicy.shouldAdd(nonTopLevelPaths[i]));
    }
    taxonomy.close();
    dir.close();
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.index.categorypolicy.PathPolicy

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.