mirror of https://github.com/apache/lucene.git
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:
parent
d77d05d44d
commit
5be38bff38
|
@ -60,6 +60,7 @@ public class CategoryPath implements Comparable<CategoryPath> {
|
||||||
|
|
||||||
/** Construct from the given path components. */
|
/** Construct from the given path components. */
|
||||||
public CategoryPath(String... components) {
|
public CategoryPath(String... components) {
|
||||||
|
assert components.length > 0 : "use CategoryPath.EMPTY to create an empty path";
|
||||||
this.components = components;
|
this.components = components;
|
||||||
length = components.length;
|
length = components.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class FacetIndexingParamsTest extends LuceneTestCase {
|
||||||
assertEquals("3 characters should be written", 3, numchars);
|
assertEquals("3 characters should be written", 3, numchars);
|
||||||
assertEquals("wrong drill-down term text", expectedDDText, new String(
|
assertEquals("wrong drill-down term text", expectedDDText, new String(
|
||||||
buf, 0, numchars));
|
buf, 0, numchars));
|
||||||
CategoryListParams clParams = dfip.getCategoryListParams(null);
|
|
||||||
assertEquals("partition for all ordinals is the first", "",
|
assertEquals("partition for all ordinals is the first", "",
|
||||||
PartitionsUtils.partitionNameByOrdinal(dfip, 250));
|
PartitionsUtils.partitionNameByOrdinal(dfip, 250));
|
||||||
assertEquals("for partition 0, the same name should be returned",
|
assertEquals("for partition 0, the same name should be returned",
|
||||||
|
@ -75,7 +74,7 @@ public class FacetIndexingParamsTest extends LuceneTestCase {
|
||||||
PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
|
PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
|
||||||
assertEquals("path policy does not match default for root", pathPolicy.shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
|
assertEquals("path policy does not match default for root", pathPolicy.shouldAdd(cp), dfip.getPathPolicy().shouldAdd(cp));
|
||||||
for (int i = 0; i < 30; i++) {
|
for (int i = 0; i < 30; i++) {
|
||||||
int nComponents = random().nextInt(10);
|
int nComponents = random().nextInt(10) + 1;
|
||||||
String[] components = new String[nComponents];
|
String[] components = new String[nComponents];
|
||||||
for (int j = 0; j < components.length; j++) {
|
for (int j = 0; j < components.length; j++) {
|
||||||
components[j] = (Integer.valueOf(random().nextInt(30))).toString();
|
components[j] = (Integer.valueOf(random().nextInt(30))).toString();
|
||||||
|
|
|
@ -131,9 +131,6 @@ public class TestCategoryPath extends LuceneTestCase {
|
||||||
CategoryPath p = new CategoryPath("hello", "world", "yo");
|
CategoryPath p = new CategoryPath("hello", "world", "yo");
|
||||||
assertEquals(3, p.length);
|
assertEquals(3, p.length);
|
||||||
assertEquals("hello/world/yo", p.toString('/'));
|
assertEquals("hello/world/yo", p.toString('/'));
|
||||||
|
|
||||||
p = new CategoryPath(new String[0]);
|
|
||||||
assertEquals(0, p.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -353,7 +353,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test TaxonomyReader.getCategory():
|
// 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 expectedCategory = new CategoryPath(expectedCategories[i]);
|
||||||
CategoryPath category = tr.getPath(i);
|
CategoryPath category = tr.getPath(i);
|
||||||
if (!expectedCategory.equals(category)) {
|
if (!expectedCategory.equals(category)) {
|
||||||
|
@ -367,7 +367,7 @@ public class TestTaxonomyCombined extends LuceneTestCase {
|
||||||
assertNull(tr.getPath(TaxonomyReader.INVALID_ORDINAL));
|
assertNull(tr.getPath(TaxonomyReader.INVALID_ORDINAL));
|
||||||
|
|
||||||
// test TaxonomyReader.getOrdinal():
|
// test TaxonomyReader.getOrdinal():
|
||||||
for (int i=0; i<expectedCategories.length; i++) {
|
for (int i = 1; i < expectedCategories.length; i++) {
|
||||||
int expectedOrdinal = i;
|
int expectedOrdinal = i;
|
||||||
int ordinal = tr.getOrdinal(new CategoryPath(expectedCategories[i]));
|
int ordinal = tr.getOrdinal(new CategoryPath(expectedCategories[i]));
|
||||||
if (expectedOrdinal != ordinal) {
|
if (expectedOrdinal != ordinal) {
|
||||||
|
|
Loading…
Reference in New Issue