Search in sources :

Example 71 with ContentItem

use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.

the class ContentItemFactoryTest method testContentReferenceId.

/**
     * Tests if the {@link ContentReference#getReference()} is used as ID for
     * the contentItem
     */
@Test
public void testContentReferenceId() throws IOException {
    ContentItem ci = contentItemFactory.createContentItem(TEST_CR);
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    assertEquals(TEST_CR.getReference(), ci.getUri().getUnicodeString());
    contentItemFactory.createContentItem(TEST_CR, new SimpleGraph());
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    assertEquals(TEST_CR.getReference(), ci.getUri().getUnicodeString());
}
Also used : SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) ContentItem(org.apache.stanbol.enhancer.servicesapi.ContentItem) Test(org.junit.Test)

Example 72 with ContentItem

use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.

the class ContentItemFactoryTest method testPrefix.

/**
     * Test that the generated ID starts with the parsed prefix
     */
@Test
public void testPrefix() throws IOException {
    ContentItem ci = contentItemFactory.createContentItem(PREFIX, TEST_CS);
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    assertTrue("The ID of the created ContentItem MUST start with the parsed prefix", ci.getUri().getUnicodeString().startsWith(PREFIX));
    ci = contentItemFactory.createContentItem(PREFIX, TEST_CS, new SimpleGraph());
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    assertTrue("The ID of the created ContentItem MUST start with the parsed prefix", ci.getUri().getUnicodeString().startsWith(PREFIX));
}
Also used : SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) ContentItem(org.apache.stanbol.enhancer.servicesapi.ContentItem) Test(org.junit.Test)

Example 73 with ContentItem

use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.

the class ContentItemFactoryTest method testDefaultId.

/**
     * Test the generation of valid IDs if no or <code>null</code> is parsed
     * as id
     */
@Test
public void testDefaultId() throws IOException {
    ContentItem ci = contentItemFactory.createContentItem(TEST_CS);
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    ci = contentItemFactory.createContentItem((IRI) null, TEST_CS);
    assertNotNull(ci);
    assertNotNull(ci.getUri());
    ci = contentItemFactory.createContentItem((IRI) null, TEST_CS, new SimpleGraph());
    assertNotNull(ci);
    assertNotNull(ci.getUri());
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) ContentItem(org.apache.stanbol.enhancer.servicesapi.ContentItem) Test(org.junit.Test)

Aggregations

ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)73 Test (org.junit.Test)62 IRI (org.apache.clerezza.commons.rdf.IRI)46 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)18 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)18 HashMap (java.util.HashMap)15 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)15 Blob (org.apache.stanbol.enhancer.servicesapi.Blob)15 StringSource (org.apache.stanbol.enhancer.servicesapi.impl.StringSource)13 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)12 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)11 Graph (org.apache.clerezza.commons.rdf.Graph)8 Date (java.util.Date)6 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)6 Hashtable (java.util.Hashtable)5 AnalysedText (org.apache.stanbol.enhancer.nlp.model.AnalysedText)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 MediaType (javax.ws.rs.core.MediaType)3 Triple (org.apache.clerezza.commons.rdf.Triple)3