for (int i = 0; i < initialCatgeories.length; i++) {
attributesList.add(new CategoryAttributeImpl(initialCatgeories[i]));
}
// test number of tokens
CategoryAttributesStream stream = new CategoryAttributesStream(
attributesList);
int nTokens = 0;
while (stream.incrementToken()) {
nTokens++;
}
assertEquals("Wrong number of tokens", 3, nTokens);
// test reset
stream.reset();
nTokens = 0;
while (stream.incrementToken()) {
nTokens++;
}
assertEquals("Wrong number of tokens", 3, nTokens);
// test reset and contents
Set<CategoryPath> pathsSet = new HashSet<CategoryPath>();
for (int i = 0; i < initialCatgeories.length; i++) {
pathsSet.add(initialCatgeories[i]);
}
stream.reset();
while (stream.incrementToken()) {
CategoryAttribute fromStream = stream
.getAttribute(CategoryAttribute.class);
if (!pathsSet.remove(fromStream.getCategoryPath())) {
fail("Unexpected category path: "
+ fromStream.getCategoryPath().toString(':'));
}