QueryResults extends Iterations { public static boolean equals(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException { List<BindingSet> list1 = Iterations.asList(tqr1); List<BindingSet> list2 = Iterations.asList(tqr2); if (list1.size() != list2.size()) { return false; } return matchBindingSets(list1, list2); }  static Model asModel(CloseableIteration<? extends Statement, ? extends RDF4JException> iteration); static Model asModel(CloseableIteration<? extends Statement, ? extends RDF4JException> iteration,
			ModelFactory modelFactory); static List<Value> getAllValues(TupleQueryResult result, String var); static Statement singleResult(GraphQueryResult result); static BindingSet singleResult(TupleQueryResult result); static GraphQueryResult distinctResults(GraphQueryResult queryResult); static TupleQueryResult distinctResults(TupleQueryResult queryResult); static TupleQueryResult limitResults(TupleQueryResult queryResult, long limit, long offset); static GraphQueryResult limitResults(GraphQueryResult queryResult, long limit, long offset); static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFFormat format); static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFParser parser); static void report(TupleQueryResult tqr, QueryResultHandler handler); static void report(GraphQueryResult gqr, RDFHandler rdfHandler); static boolean equals(TupleQueryResult tqr1, TupleQueryResult tqr2); static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2); static boolean equals(GraphQueryResult result1, GraphQueryResult result2); static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2);  }
@Test public void testStreamGraphResult() { List<Statement> aboutA = gqr.stream() .filter(s -> s.getSubject().equals(a)) .collect(Collectors.toList()); assertFalse(aboutA.isEmpty()); for (Statement st : aboutA) { assertTrue(st.getSubject().equals(a)); } }
@Test public void testStreamTupleResult() { BindingSet a = new ListBindingSet(twoBindingNames, foo, lit1); BindingSet b = new ListBindingSet(twoBindingNames, bar, lit2); tqr1.append(a); tqr1.append(b); tqr1.append(a); tqr1.append(b); tqr1.append(b); List<BindingSet> list = tqr1.stream() .filter(bs -> bs.getValue("a").equals(foo)) .collect(Collectors.toList()); assertNotNull(list); assertFalse(list.isEmpty()); for (BindingSet bs : list) { assertTrue(bs.getValue("a").equals(foo)); } }
@Test public void testGraphQueryResultEquals() throws QueryEvaluationException { StubGraphQueryResult toCompare = new StubGraphQueryResult(); assertTrue(QueryResults.equals(gqr, toCompare)); gqr = new StubGraphQueryResult(); toCompare = new StubGraphQueryResult(); toCompare.statements.add(VF.createStatement(VF.createURI("urn:test-gqr-equals"), RDF.TYPE, RDF.PROPERTY)); assertFalse(QueryResults.equals(gqr, toCompare)); }
@Test public void testEmptyQueryResult() throws QueryEvaluationException { tqr1.append(EmptyBindingSet.getInstance()); tqr2.append(EmptyBindingSet.getInstance()); tqr3.append(EmptyBindingSet.getInstance()); assertTrue(QueryResults.equals(tqr1, tqr2)); }
@Test public void testEmptyQueryResult2() throws QueryEvaluationException { tqr1.append(EmptyBindingSet.getInstance()); tqr3.append(EmptyBindingSet.getInstance()); assertTrue(QueryResults.equals(tqr1, tqr3)); }
@Test public void testEmptyQueryResult3() throws QueryEvaluationException { tqr1.append(EmptyBindingSet.getInstance()); tqr3.append(EmptyBindingSet.getInstance()); assertTrue(QueryResults.equals(tqr3, tqr1)); }
@Test public void testEmptyBindingSet() throws QueryEvaluationException { tqr1.append(EmptyBindingSet.getInstance()); tqr2.append(EmptyBindingSet.getInstance()); assertTrue(QueryResults.equals(tqr1, tqr2)); }
@Test public void testNonBNodeBindingSet1() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1)); tqr1.append(new ListBindingSet(twoBindingNames, bar, lit2)); tqr2.append(new ListBindingSet(twoBindingNames, bar, lit2)); tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1)); assertTrue(QueryResults.equals(tqr1, tqr2)); }
@Test public void testNonBNodeBindingSet2() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, lit2)); assertFalse(QueryResults.equals(tqr1, tqr2)); }
@Test public void testNonBNodeBindingSet3() throws QueryEvaluationException { tqr3.append(new ListBindingSet(threeBindingNames, foo, lit1, bar)); tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1)); assertFalse(QueryResults.equals(tqr3, tqr2)); }
@Test public void testNonBNodeBindingSet() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, lit2)); assertFalse(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet1() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode1)); tqr1.append(new ListBindingSet(twoBindingNames, bar, bnode2)); tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode2)); tqr2.append(new ListBindingSet(twoBindingNames, bar, bnode1)); assertTrue(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet2() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1)); assertFalse(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet3() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode1)); tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2)); tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1)); assertFalse(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet4() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, bnode1, bnode2)); tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2)); tqr2.append(new ListBindingSet(twoBindingNames, bnode2, bnode1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1)); assertTrue(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet5() throws QueryEvaluationException { tqr1.append(new ListBindingSet(twoBindingNames, bnode1, bnode2)); tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2)); tqr2.append(new ListBindingSet(twoBindingNames, bnode2, bnode1)); tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode2)); assertFalse(QueryResults.equals(tqr1, tqr2)); }
@Test public void testBNodeBindingSet6() throws QueryEvaluationException { tqr3.append(new ListBindingSet(threeBindingNames, foo, bnode2, bnode1)); tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2)); assertFalse(QueryResults.equals(tqr3, tqr1)); }
@Test public void testBNodeBindingSet7() throws QueryEvaluationException { tqr3.append(new ListBindingSet(threeBindingNames, foo, bnode2, bnode1)); tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2)); assertFalse(QueryResults.equals(tqr1, tqr3)); }