// test if an entity (the topic) is referred (NOTE: in contrast to
// fise:EntityAnnotations this property is NOT required - cardinality [0..*]
Iterator<Triple> entityReferenceIterator = enhancements.filter(topicAnnotation,
ENHANCER_ENTITY_REFERENCE, null);
Resource expectedReferencedEntity = expectedValues.get(ENHANCER_ENTITY_REFERENCE);
while(entityReferenceIterator.hasNext()){ //check possible multiple references
Resource entityReferenceResource = entityReferenceIterator.next().getObject();
// test if the reference is an URI
assertTrue("fise:entity-reference value MUST BE of URIs",entityReferenceResource instanceof UriRef);
if(expectedReferencedEntity != null && expectedReferencedEntity.equals(entityReferenceResource)){
expectedReferencedEntity = null; //found
}
}
assertNull("EntityAnnotation "+topicAnnotation+"fise:entity-reference has not the expected value "
+expectedReferencedEntity+"!", expectedReferencedEntity);
//test if the entity label is set (required)
Iterator<Triple> entityLabelIterator = enhancements.filter(topicAnnotation, ENHANCER_ENTITY_LABEL, null);
assertTrue(entityLabelIterator.hasNext());
Resource expectedEntityLabel = expectedValues.get(ENHANCER_ENTITY_LABEL);
while(entityLabelIterator.hasNext()){
Resource entityLabelResource = entityLabelIterator.next().getObject();
assertTrue("fise:entity-label values MUST BE PlainLiterals (EntityAnnotation: "+topicAnnotation+")!",
entityLabelResource instanceof PlainLiteral);
if(expectedEntityLabel != null && expectedEntityLabel.equals(entityLabelResource)){
expectedEntityLabel = null;
}
}
assertNull("The expected EntityLabel "+expectedEntityLabel+" was not found",
expectedEntityLabel);
// test fise:entity-type(s). NOTE: this is not required - cardinality [0..*]
Iterator<Triple> entityTypeIterator = enhancements.filter(topicAnnotation, Properties.ENHANCER_ENTITY_TYPE, null);
Resource expectedEntityType = expectedValues.get(Properties.ENHANCER_ENTITY_TYPE);
if(entityTypeIterator.hasNext()){
Resource entityTypeResource = entityTypeIterator.next().getObject();
assertTrue("fise:entity-type values MUST BE URIs",entityTypeResource instanceof UriRef);
if(expectedEntityType != null && expectedEntityType.equals(entityTypeResource)){
expectedEntityType = null; //found
}
}