@Override public Set<ReifiedStatement> toSet() { return iter.toSet(); } }
@Override public Set<Resource> toSet() { return iter.toSet(); } }
/** * Constructor. * * @param graph * the default graph name for the triples * @param triples * the iterator of triples. */ public CollectionQuadHolder(final Node graph, Iterator<Triple> triples) { this.collection = WrappedIterator.create( triples ).toSet(); defaultGraphName = graph; }
/** Return an iterator over the unique predicate between s and o. * s and o can be wildcards (Node.ANY) * @param g Graph * @param s Subject - may be Node.ANY * @param o Object - may be Node.ANY * @return ExtendedIterator */ public static ExtendedIterator<Node> listPredicates(Graph g, Node s, Node o) { ExtendedIterator<Triple> iter = g.find(s,Node.ANY, o) ; Set<Node> nodes = iter.mapWith(t -> t.getPredicate()).toSet() ; return WrappedIterator.createNoRemove(nodes.iterator()) ; }
/** Test that a maker with no graphs lists no names. */ public void testListNoGraphs() { Set<String> s = gf.listGraphs().toSet(); if (s.size() > 0) fail( "found names from 'empty' graph maker: " + s ); }
private Set<String> testReturnsSet( String elements ) { Set<String> result = setOfStrings( elements ); assertEquals( result, WrappedIterator.create( result.iterator() ).toSet() ); return result; }
/** * Test that a maker with no graphs lists no names. */ @ContractTest public void testListNoGraphs() { Set<String> s = graphMaker.listGraphs().toSet(); if (s.size() > 0) fail("found names from 'empty' graph maker: " + s); }
public void testKeyIterator() { ProbeHashCommon h = probeWith( "0:0:X" ); Set<?> elements = h.keyIterator().toSet(); assertEquals( itemSet( "0:X" ), elements ); }
public void testRemoveByIterator() { addTriples( ntS, "x nice a; a nasty b; x nice c" ); addTriples( ntS, "y nice d; y nasty e; y nice f" ); Iterator<Triple> it = ntS.iterateAll(); while (it.hasNext()) { Triple t = it.next(); if (t.getPredicate().equals( node( "nasty") )) it.remove(); } assertEquals( tripleSet( "x nice a; x nice c; y nice d; y nice f" ), ntS.iterateAll().toSet() ); }
@ContractTest public void testFind_Triple_ByFluidTriple() { Graph g = graphWith(producer.newInstance(), "x y z "); Set<Triple> expect = tripleSet("x y z"); txnBegin(g); assertEquals(expect, g.find(triple("?? y z")).toSet()); assertEquals(expect, g.find(triple("x ?? z")).toSet()); assertEquals(expect, g.find(triple("x y ??")).toSet()); txnRollback(g); }
/** * Cycle bug in transitive reasoner */ public void testTransitiveCycleBug() { Model m = FileManager.get().loadModel( "file:testing/reasoners/bugs/unbroken.n3" ); OntModel om = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM_TRANS_INF, m ); OntClass rootClass = om.getOntClass( RDFS.Resource.getURI() ); Resource c = m.getResource("c"); Set<OntClass> direct = rootClass.listSubClasses( true ).toSet(); assertFalse( direct.contains( c ) ); } /**
public void testUnspecificRemoveO() { addTriples( ntO, "x P a; y Q b; z R c" ); ntO.remove( triple( "z R c" ) ); assertEquals( tripleSet( "x P a; y Q b" ), ntO.iterateAll().toSet() ); }
public void testReifierFindFilter() { Graph g = getGraph(); graphAdd( g, "s rdf:subject S" ); assertEquals( tripleSet( "" ), ReifierStd.findExposed( g, triple( "s otherPredicate S" ) ).toSet() ); }
public void testUnspecificRemoveP() { addTriples( ntP, "x P a; y Q b; z R c" ); ntP.remove( triple( "y Q b" ) ); assertEquals( tripleSet( "x P a; z R c" ), ntP.iterateAll().toSet() ); }
public void testUnspecificRemoveS() { addTriples( ntS, "x P a; y Q b; z R c" ); ntS.remove( triple( "x P a" ) ); assertEquals( tripleSet( "y Q b; z R c" ), ntS.iterateAll().toSet() ); }
public void testRemove() { addTriples( ntS, "x P b; y P d; y R f" ); ntS.remove( triple( "y P d" ) ); assertEquals( 2, ntS.size() ); assertEquals( tripleSet( "x P b; y R f" ), ntS.iterateAll().toSet() ); }
public void testIterator() { TripleBunch b = getBunch(); b.add( triple( "a P b" ) ); b.add( triple( "c Q d" ) ); b.add( triple( "e R f" ) ); assertEquals( tripleSet( "a P b; c Q d; e R f" ), b.iterator().toSet() ); }
@ContractTest public void testIteratorRemoveOneItem() { testingBunch.add(triple("a P b")); testingBunch.add(triple("c Q d")); testingBunch.add(triple("e R f")); ExtendedIterator<Triple> it = testingBunch.iterator(); while (it.hasNext()) if (it.next().equals(triple("c Q d"))) it.remove(); assertEquals(tripleSet("a P b; e R f"), testingBunch.iterator().toSet()); }