Search in sources :

Example 1 with EntityDataIterable

use of org.apache.stanbol.entityhub.indexing.core.EntityDataIterable in project stanbol by apache.

the class RdfIndexingSourceTest method testBlankNodeSupport.

@Test
public void testBlankNodeSupport() {
    log.info(" --- testBlankNodeSupport ---");
    String testName = "bnode";
    IndexingConfig config = new IndexingConfig(CONFIG_ROOT + File.separatorChar + testName, CONFIG_ROOT + '/' + testName) {
    };
    EntityDataIterable iterable = config.getDataIterable();
    assertNotNull(iterable);
    assertEquals(iterable.getClass(), RdfIndexingSource.class);
    assertTrue(iterable.needsInitialisation());
    iterable.initialise();
    // ((RdfIndexingSource)iterable).debug();
    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
    // Expected are 3 entities First France from france.rdf
    // and two from BlankNode Entities in bnode.nt
    assertEquals(String.format("> %s Entities expected but only %s processed!", 3, count), 3, count);
}
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)

Example 2 with EntityDataIterable

use of org.apache.stanbol.entityhub.indexing.core.EntityDataIterable 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();
    assertNotNull(iterable);
    assertEquals(iterable.getClass(), RdfIndexingSource.class);
    assertTrue(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);
}
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)

Example 3 with EntityDataIterable

use of org.apache.stanbol.entityhub.indexing.core.EntityDataIterable 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

EntityDataIterable (org.apache.stanbol.entityhub.indexing.core.EntityDataIterable)3 EntityDataIterator (org.apache.stanbol.entityhub.indexing.core.EntityDataIterator)3 IndexingConfig (org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)3 Test (org.junit.Test)3