/**
* Test the removeRelation functionality.
*/
public void testRemove() {
TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
cache.addRelation(new Triple(a, closedP, b));
cache.addRelation(new Triple(a, closedP, c));
cache.addRelation(new Triple(b, closedP, d));
cache.addRelation(new Triple(c, closedP, d));
cache.addRelation(new Triple(d, closedP, e));
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(a, closedP, null)),
new Object[] {
new Triple(a, closedP, a),
new Triple(a, closedP, b),
new Triple(a, closedP, b),
new Triple(a, closedP, c),
new Triple(a, closedP, d),
new Triple(a, closedP, e)
});
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(b, closedP, null)),
new Object[] {
new Triple(b, closedP, b),
new Triple(b, closedP, d),
new Triple(b, closedP, e)
});
cache.removeRelation(new Triple(b, closedP, d));
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(a, closedP, null)),
new Object[] {
new Triple(a, closedP, a),
new Triple(a, closedP, b),
new Triple(a, closedP, b),
new Triple(a, closedP, c),
new Triple(a, closedP, d),
new Triple(a, closedP, e)
});
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(b, closedP, null)),
new Object[] {
new Triple(b, closedP, b),
});
cache.removeRelation(new Triple(a, closedP, c));
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(a, closedP, null)),
new Object[] {
new Triple(a, closedP, a),
new Triple(a, closedP, b)
});
TestUtil.assertIteratorValues(this,
cache.find(new TriplePattern(b, closedP, null)),
new Object[] {
new Triple(b, closedP, b),
});
}