*/
protected abstract MGraph getEmptyMGraph();
@Test
public void testAddCountAndGetTriples() {
MGraph graph = getEmptyMGraph();
Assert.assertEquals(0, graph.size());
final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
graph.add(triple1);
Assert.assertEquals(1, graph.size());
Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, uriRef1);
Assert.assertTrue(tripleIter.hasNext());
Triple tripleGot = tripleIter.next();
Assert.assertEquals(triple1, tripleGot);
Assert.assertFalse(tripleIter.hasNext());
BNode bnode = new BNode() {};
graph.add(new TripleImpl(bnode, uriRef1, uriRef3));
graph.add(new TripleImpl(bnode, uriRef1, uriRef4));
tripleIter = graph.filter(null, uriRef1, null);
Set<NonLiteral> subjectInMatchingTriples = new HashSet<NonLiteral>();
Set<Resource> objectsInMatchingTriples = new HashSet<Resource>();
while (tripleIter.hasNext()) {
Triple triple = tripleIter.next();
subjectInMatchingTriples.add(triple.getSubject());
objectsInMatchingTriples.add(triple.getObject());
}
Assert.assertEquals(1, subjectInMatchingTriples.size());
Assert.assertEquals(2, objectsInMatchingTriples.size());
Set<Resource> expectedObjects = new HashSet<Resource>();
expectedObjects.add(uriRef3);
expectedObjects.add(uriRef4);
Assert.assertEquals(expectedObjects, objectsInMatchingTriples);
graph.add(new TripleImpl(bnode, uriRef4, bnode));
tripleIter = graph.filter(null, uriRef4, null);
Assert.assertTrue(tripleIter.hasNext());
Triple retrievedTriple = tripleIter.next();
Assert.assertFalse(tripleIter.hasNext());
Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
tripleIter = graph.filter(uriRef1, uriRef2, null);
Assert.assertTrue(tripleIter.hasNext());
retrievedTriple = tripleIter.next();
Assert.assertFalse(tripleIter.hasNext());
Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
}