You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/01/21 13:54:37 UTC

svn commit: r1436321 - in /lucene/dev/trunk/lucene/facet/src: java/org/apache/lucene/facet/taxonomy/ test/org/apache/lucene/facet/index/params/ test/org/apache/lucene/facet/taxonomy/

Author: shaie
Date: Mon Jan 21 12:54:37 2013
New Revision: 1436321

URL: http://svn.apache.org/viewvc?rev=1436321&view=rev
Log:
add assert to CategoryPath(String...) constructor

Modified:
    lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java

Modified: lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java?rev=1436321&r1=1436320&r2=1436321&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java (original)
+++ lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java Mon Jan 21 12:54:37 2013
@@ -60,6 +60,7 @@ public class CategoryPath implements Com
   
   /** Construct from the given path components. */
   public CategoryPath(String... components) {
+    assert components.length > 0 : "use CategoryPath.EMPTY to create an empty path";
     this.components = components;
     length = components.length;
   }

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java?rev=1436321&r1=1436320&r2=1436321&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java (original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java Mon Jan 21 12:54:37 2013
@@ -46,7 +46,6 @@ public class FacetIndexingParamsTest ext
     assertEquals("3 characters should be written", 3, numchars);
     assertEquals("wrong drill-down term text", expectedDDText, new String(
         buf, 0, numchars));
-    CategoryListParams clParams = dfip.getCategoryListParams(null);
     assertEquals("partition for all ordinals is the first", "", 
         PartitionsUtils.partitionNameByOrdinal(dfip, 250));
     assertEquals("for partition 0, the same name should be returned",
@@ -75,7 +74,7 @@ public class FacetIndexingParamsTest ext
     PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
     assertEquals("path policy does not match default for root", pathPolicy.shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
     for (int i = 0; i < 30; i++) {
-      int nComponents = random().nextInt(10);
+      int nComponents = random().nextInt(10) + 1;
       String[] components = new String[nComponents];
       for (int j = 0; j < components.length; j++) {
         components[j] = (Integer.valueOf(random().nextInt(30))).toString();

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java?rev=1436321&r1=1436320&r2=1436321&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java (original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java Mon Jan 21 12:54:37 2013
@@ -131,9 +131,6 @@ public class TestCategoryPath extends Lu
     CategoryPath p = new CategoryPath("hello", "world", "yo");
     assertEquals(3, p.length);
     assertEquals("hello/world/yo", p.toString('/'));
-    
-    p = new CategoryPath(new String[0]);
-    assertEquals(0, p.length);
   }
   
   @Test 

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java?rev=1436321&r1=1436320&r2=1436321&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java (original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java Mon Jan 21 12:54:37 2013
@@ -353,7 +353,7 @@ public class TestTaxonomyCombined extend
     }
 
     // test TaxonomyReader.getCategory():
-    for (int i=0; i<tr.getSize(); i++) {
+    for (int i = 1; i < tr.getSize(); i++) {
       CategoryPath expectedCategory = new CategoryPath(expectedCategories[i]);
       CategoryPath category = tr.getPath(i);
       if (!expectedCategory.equals(category)) {
@@ -367,7 +367,7 @@ public class TestTaxonomyCombined extend
     assertNull(tr.getPath(TaxonomyReader.INVALID_ORDINAL));
 
     // test TaxonomyReader.getOrdinal():
-    for (int i=0; i<expectedCategories.length; i++) {
+    for (int i = 1; i < expectedCategories.length; i++) {
       int expectedOrdinal = i;
       int ordinal = tr.getOrdinal(new CategoryPath(expectedCategories[i]));
       if (expectedOrdinal != ordinal) {