Map<String, ? extends TestCase<?>> tests) {
List<TestRunResult> results = new ArrayList<TestRunResult>();
for( OWLClassAssertionAxiom axiom : o.getClassAssertionAxioms( TEST_RUN.getOWLClass() ) ) {
final OWLNamedIndividual i = axiom.getIndividual().asOWLNamedIndividual();
final Map<OWLObjectPropertyExpression, Set<OWLIndividual>> oValues = i
.getObjectPropertyValues( o );
Set<OWLIndividual> testObjects = oValues.get( TEST.getOWLObjectProperty() );
if( testObjects.size() != 1 ) {
log.warning( format(
"Skipping result, missing or more than one test assertion (\"%s\",%s)", i
.getIRI(), testObjects ) );
continue;
}
Map<OWLDataPropertyExpression, Set<OWLLiteral>> testDValues = testObjects.iterator()
.next().getDataPropertyValues( o );
Set<OWLLiteral> ids = testDValues.get( IDENTIFIER.getOWLDataProperty() );
TestCase<?> testCase = null;
for( OWLLiteral c : ids ) {
String id = c.getLiteral();
testCase = tests.get( id );
if( testCase != null )
break;
}
if( testCase == null ) {
log.warning( format( "Skipping result, no matching test case found (\"%s\",%s)", i
.getIRI(), ids ) );
continue;
}
Set<OWLIndividual> runnerIris = oValues.get( RUNNER.getOWLObjectProperty() );
TestRunner<?> runner = null;
if( runnerIris.size() != 1 ) {
log
.warning( format(
"Skipping result, missing or more than one test runner assertion (\"%s\",%s)",
i.getIRI(), runnerIris ) );
continue;
}
runner = getRunner( runnerIris.iterator().next().asOWLNamedIndividual(), o );
Set<OWLClassExpression> types = i.getTypes( o );
RunResultType resultType = null;
for( RunResultType t : RunResultType.values() ) {
if( types.contains( t.getOWLClass() ) ) {
resultType = t;
break;
}
}
if( resultType == null ) {
log.warning( format( "Skipping result, missing result type (\"%s\")", i.getIRI() ) );
continue;
}
@SuppressWarnings("unchecked")
Set<OWLAnnotation> detailsAnnotations = i.getAnnotations( o, o.getOWLOntologyManager()
.getOWLDataFactory().getOWLAnnotationProperty(
DETAILS.getAnnotationPropertyIRI() ) );
String details = null;
int ndetails = detailsAnnotations.size();
if( ndetails > 0 ) {
if( ndetails > 1 )
log
.info( format(
"Result contains multiple details annotations, ignoring all but first (\"%s\")",
i.getIRI() ) );
details = detailsAnnotations.iterator().next().getValue().toString();
}
TestRunResult result = null;
if( types.contains( SYNTAX_TRANSLATION_RUN.getOWLClass() ) ) {
result = (details == null)
? new SyntaxTranslationRun( testCase, resultType, runner )
: new SyntaxTranslationRun( testCase, resultType, runner, details );
}
else if( types.contains( SYNTAX_CONSTRAINT_RUN.getOWLClass() ) ) {
Set<OWLIndividual> constraints = oValues.get( SYNTAX_CONSTRAINT
.getOWLObjectProperty() );
SyntaxConstraint constraint = null;
if( constraints.size() != 1 ) {
log
.warning( format(
"Skipping result, missing or more than one syntax constraint assertion (\"%s\",%s)",
i.getIRI(), constraints ) );
continue;
}
OWLNamedIndividual ind = constraints.iterator().next().asOWLNamedIndividual();
for( SyntaxConstraint c : SyntaxConstraint.values() ) {
if( c.getOWLIndividual().equals( ind ) ) {
constraint = c;
break;
}