use of org.apache.stanbol.entityhub.indexing.core.EntityDataIterator in project stanbol by apache.
the class RdfIndexingSourceTest method testEntityDataIterable.
@Test
public void testEntityDataIterable() {
log.info(" --- testEntityDataIterable ---");
String testName = "iterable";
IndexingConfig config = new IndexingConfig(CONFIG_ROOT + File.separatorChar + testName, CONFIG_ROOT + '/' + testName) {
};
EntityDataIterable iterable = config.getDataIterable();
try {
assertNotNull(iterable);
assertEquals(iterable.getClass(), RdfIndexingSource.class);
if (iterable.needsInitialisation()) {
iterable.initialise();
}
EntityDataIterator it = iterable.entityDataIterator();
long count = 0;
while (it.hasNext()) {
String entity = it.next();
log.info("validate Entity " + entity);
assertNotNull(entity);
validateRepresentation(it.getRepresentation(), entity);
count++;
}
//check if all entities where indexed
//this checks if more entities are indexed as listed by the
//textEntityIDs.txt file
assertTrue(String.format("> %s Entities expected but only %s processed!", NUMBER_OF_ENTITIES_EXPECTED, count), NUMBER_OF_ENTITIES_EXPECTED <= count);
} finally {
//we need to ensure close is called as otherwise other tests might fail
iterable.close();
}
}
Aggregations