private static final Logger log = Logger.getLogger(ResultSetUtils.class.getName());
private static final RDFNode DUMMY_FOR_BNODE = ResourceFactory.createPlainLiteral("dummy node for bnode");
public static boolean assertEquals(ResultSet expectedResults, ResultSet computedResults) {
ResultSetRewindable expected = ResultSetFactory.makeRewindable( expectedResults );
ResultSetRewindable computed = ResultSetFactory.makeRewindable( computedResults );
System.out.println( "Computed: " + computed.size() + " Expected: " + expected.size() );
if( expected.size() != computed.size() ) {
logResults( "Expected", expected );
logResults( "Real", computed );
Assert.fail( "Expected " + expected.size() + " but got " + computed.size() );
}
List<String> vars = expected.getResultVars();
Collection<Map<String, RDFNode>> results = results( computed );
for( expected.reset(); expected.hasNext(); ) {
QuerySolution qs = expected.nextSolution();
Map<String, RDFNode> map = solutionMap(qs, vars);
if( !results.contains( map ) ) {
logResults( "Expected", expected );
logResults( "Real", computed );
Assert.fail( "Solution not found: " + map );
Assert.fail( "Expected " + expected.size() + " but got " + computed.size() );
}
}
return true;
}