Search in sources :

Example 6 with EntityDataIterator

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();
    }
}
Also used : IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig) EntityDataIterable(org.apache.stanbol.entityhub.indexing.core.EntityDataIterable) EntityDataIterator(org.apache.stanbol.entityhub.indexing.core.EntityDataIterator) Test(org.junit.Test)

Aggregations

EntityDataIterator (org.apache.stanbol.entityhub.indexing.core.EntityDataIterator)6 EntityDataIterable (org.apache.stanbol.entityhub.indexing.core.EntityDataIterable)3 IndexingConfig (org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)3 Test (org.junit.Test)3 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 NoSuchElementException (java.util.NoSuchElementException)1 StringTokenizer (java.util.StringTokenizer)1 LineIterator (org.apache.commons.io.LineIterator)1 RepositoryException (org.openrdf.repository.RepositoryException)1