use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.
the class ContentItemTest method addingAndRetrieving.
@Test
public void addingAndRetrieving() throws IOException {
ContentItem ci = createContentItem(contentSource);
assertNotNull(ci);
assertNotNull(ci.getUri());
IRI partUri = new IRI("http://foo/");
Date someObject = new Date();
ci.addPart(partUri, someObject);
ci.getMetadata().add(new TripleImpl(ci.getUri(), new IRI("http://example.org/ontology#hasPart"), partUri));
ci.getMetadata().add(new TripleImpl(partUri, new IRI("http://example.org/ontology#isPartOf"), ci.getUri()));
assertEquals(someObject, ci.getPart(partUri, Date.class));
assertEquals(someObject, ci.getPart(1, Date.class));
assertEquals(partUri, ci.getPartUri(1));
assertEquals(new IRI(ci.getUri().getUnicodeString() + "_main"), ci.getPartUri(0));
try {
ci.getPart(2, Object.class);
assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
} catch (NoSuchPartException e) {
/* expected*/
}
try {
ci.getPart(new IRI("http://foo/nonexisting"), Object.class);
assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
} catch (NoSuchPartException e) {
/* expected*/
}
try {
ci.getPartUri(2);
assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
} catch (NoSuchPartException e) {
/* expected*/
}
//finally log the toString
log.info("toString: {}", ci);
}
use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.
the class ContentItemTest method addPartWithoutUri.
@Test(expected = IllegalArgumentException.class)
public void addPartWithoutUri() throws IOException {
ContentItem ci = createContentItem(contentSource);
ci.addPart(null, new Date());
}
use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.
the class ContentItemTest method removeMainContentPartByIndex.
@Test(expected = IllegalStateException.class)
public void removeMainContentPartByIndex() throws IOException {
ContentItem ci = createContentItem(contentSource);
ci.removePart(0);
}
use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.
the class ContentItemTest method removeMainContentPartByUri.
@Test(expected = IllegalStateException.class)
public void removeMainContentPartByUri() throws IOException {
ContentItem ci = createContentItem(contentSource);
ci.removePart(ci.getPartUri(0));
}
use of org.apache.stanbol.enhancer.servicesapi.ContentItem in project stanbol by apache.
the class DereferenceEngineTest method testAsyncDereferencing.
@Test
public void testAsyncDereferencing() throws Exception {
ContentItem ci = getContentItem("urn:test:testSyncDereferencing");
Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(EnhancementEngine.PROPERTY_NAME, "async");
dict.put(FILTER_CONTENT_LANGUAGES, false);
dict.put(FILTER_ACCEPT_LANGUAGES, false);
EntityDereferenceEngine engine = new EntityDereferenceEngine(asyncDereferencer, new DereferenceEngineConfig(dict, null));
Assert.assertNotEquals(engine.canEnhance(ci), EnhancementEngine.CANNOT_ENHANCE);
engine.computeEnhancements(ci);
validateDereferencedEntities(ci.getMetadata(), ENHANCER_ENTITY_REFERENCE);
}
Aggregations