From 5be38bff380ef844e1bc1b2b8a825af03f639347 Mon Sep 17 00:00:00 2001 From: Shai Erera Date: Mon, 21 Jan 2013 12:54:37 +0000 Subject: [PATCH] add assert to CategoryPath(String...) constructor git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1436321 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/lucene/facet/taxonomy/CategoryPath.java | 1 + .../lucene/facet/index/params/FacetIndexingParamsTest.java | 3 +-- .../org/apache/lucene/facet/taxonomy/TestCategoryPath.java | 3 --- .../apache/lucene/facet/taxonomy/TestTaxonomyCombined.java | 4 ++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java index 61bd1548032..27f7a250888 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java @@ -60,6 +60,7 @@ public class CategoryPath implements Comparable { /** 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; } diff --git a/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java b/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java index de5f233072e..522ba787b0f 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java @@ -46,7 +46,6 @@ public class FacetIndexingParamsTest extends LuceneTestCase { 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 extends LuceneTestCase { 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(); diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java index ccaaf4d33ec..ce3f29f7634 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java @@ -131,9 +131,6 @@ public class TestCategoryPath extends LuceneTestCase { 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 diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java index 33168b0b6ef..2225f96ade3 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java @@ -353,7 +353,7 @@ public class TestTaxonomyCombined extends LuceneTestCase { } // test TaxonomyReader.getCategory(): - for (int i=0; i