1
package org.apache.lucene.facet.index.attributes;
3
import java.io.IOException;
4
import java.util.ArrayList;
5
import java.util.Iterator;
10
import org.apache.lucene.facet.index.CategoryContainerTestBase;
11
import org.apache.lucene.facet.index.attributes.CategoryAttribute;
12
import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
13
import org.apache.lucene.facet.taxonomy.CategoryPath;
16
* Licensed to the Apache Software Foundation (ASF) under one or more
17
* contributor license agreements. See the NOTICE file distributed with
18
* this work for additional information regarding copyright ownership.
19
* The ASF licenses this file to You under the Apache License, Version 2.0
20
* (the "License"); you may not use this file except in compliance with
21
* the License. You may obtain a copy of the License at
23
* http://www.apache.org/licenses/LICENSE-2.0
25
* Unless required by applicable law or agreed to in writing, software
26
* distributed under the License is distributed on an "AS IS" BASIS,
27
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
* See the License for the specific language governing permissions and
29
* limitations under the License.
32
public class CategoryAttributesIterableTest extends CategoryContainerTestBase {
35
public void testIterator() throws IOException {
36
List<CategoryPath> categoryList = new ArrayList<CategoryPath>();
37
for (int i = 0; i < initialCatgeories.length; i++) {
38
categoryList.add(initialCatgeories[i]);
41
CategoryAttributesIterable iterable = new CategoryAttributesIterable(
43
Iterator<CategoryAttribute> iterator = iterable.iterator();
45
// count the number of tokens
47
for (nCategories = 0; iterator.hasNext(); nCategories++) {
50
assertEquals("Wrong number of tokens", 3, nCategories);