public void testBulkByModelReifying(boolean suppress) { Model m = modelWithStatements(ReificationStyle.Minimal, "a P b"); addReification(m, "x", "S P O"); addReification(m, "a", "x R y"); Model target = modelWithStatements(ReificationStyle.Minimal, ""); target.add(m, suppress); target.setNsPrefixes(PrefixMapping.Standard); assertIsoModels((suppress ? modelWithStatements("a P b") : m), target); }
public void testBulkDeleteByModelReifying(boolean suppress) { Model target = modelWithStatements(ReificationStyle.Minimal, ""); addReification(target, "x", "S P O"); addReification(target, "y", "A P B"); Model remove = modelWithStatements(""); addReification(remove, "y", "A P B"); Model answer = modelWithStatements(""); addReification(answer, "x", "S P O"); if (suppress) addReification(answer, "y", "A P B"); target.remove(remove, suppress); assertIsoModels(answer, target); }
public void testMBU(Model m) { Statement[] sArray = statements(m, "moon orbits earth; earth orbits sun"); List<Statement> sList = Arrays.asList(statements(m, "I drink tea; you drink coffee")); m.add(sArray); testContains(m, sArray); m.add(sList); testContains(m, sList); testContains(m, sArray); /* */ m.remove(sArray); testOmits(m, sArray); testContains(m, sList); m.remove(sList); testOmits(m, sArray); testOmits(m, sList); }
/** * @param mGraph * @return */ protected static Graph getHiddenTriples(Model m) { Graph mGraph = m.getGraph(); final Reifier r = mGraph.getReifier(); return new GraphBase() { public ExtendedIterator graphBaseFind(TripleMatch m) { return r.findEither(m, true); } }; }
public void testBulkByModel(Model m) { assertEquals("precondition: model must be empty", 0, m.size()); Model A = modelWithStatements("clouds offer rain; trees offer shelter"); Model B = modelWithStatements("x R y; y Q z; z P x"); m.add(A); assertIsoModels(A, m); m.add(B); m.remove(A); assertIsoModels(B, m); m.remove(B); assertEquals("", 0, m.size()); }
/** * Answer a version of the model, but with all its reifiying statements added. * * @param m a model that may have reified statements * @return a new model, the union of m and the reification statements of m */ public static Model withHiddenStatements(Model m) { Graph mGraph = m.getGraph(); Graph hiddenTriples = getHiddenTriples(m); return new ModelCom(new DisjointUnion(mGraph, hiddenTriples)); }
public void testBulkRemoveSelf() { Model m = modelWithStatements("they sing together; he sings alone"); m.remove(m); assertEquals("", 0, m.size()); }
public void testOmits(Model m, List<Statement> statements) { for (int i = 0; i < statements.size(); i += 1) assertFalse("it should not be here", m.contains(statements.get(i))); }
public void testOmits(Model m, Statement[] statements) { for (int i = 0; i < statements.length; i += 1) assertFalse("it should not be here", m.contains(statements[i])); }
public void addReification(Model m, String tag, String statement) { m.createReifiedStatement(tag, statement(m, statement)); }