add assert to CategoryPath(String...) constructor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1436321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-01-21 12:54:37 +00:00
parent d77d05d44d
commit 5be38bff38
4 changed files with 4 additions and 7 deletions

View File

@ -60,6 +60,7 @@ public class CategoryPath implements Comparable<CategoryPath> {
/** 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;
}

View File

@ -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();

View File

@ -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

View File

@ -353,7 +353,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
}
// 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 extends LuceneTestCase {
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) {