Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 /**
  * @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);
     }
   };
 }
Exemplo n.º 5
0
 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());
 }
Exemplo n.º 6
0
 /**
  * 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));
 }
Exemplo n.º 7
0
 public void testBulkRemoveSelf() {
   Model m = modelWithStatements("they sing together; he sings alone");
   m.remove(m);
   assertEquals("", 0, m.size());
 }
Exemplo n.º 8
0
 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)));
 }
Exemplo n.º 9
0
 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]));
 }
Exemplo n.º 10
0
 public void addReification(Model m, String tag, String statement) {
   m.createReifiedStatement(tag, statement(m, statement));
 }