clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1538951 - in /clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing: ./ SameAsSmushTest.java
Date Tue, 05 Nov 2013 11:40:48 GMT
Author: reto
Date: Tue Nov  5 11:40:47 2013
New Revision: 1538951

URL: http://svn.apache.org/r1538951
Log:
CLEREZZA-830: added Test for owl:sameAs smushing

Added:
    clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/
    clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
      - copied, changed from r1538946, clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java

Copied: clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
(from r1538946, clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java)
URL: http://svn.apache.org/viewvc/clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java?p2=clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java&p1=clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java&r1=1538946&r2=1538951&rev=1538951&view=diff
==============================================================================
--- clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java
(original)
+++ clerezza/trunk/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
Tue Nov  5 11:40:47 2013
@@ -16,9 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.clerezza.rdf.utils;
+package org.apache.clerezza.rdf.utils.smushing;
 
 import java.util.Iterator;
+import java.util.Set;
 import org.apache.clerezza.rdf.core.BNode;
 import org.apache.clerezza.rdf.core.Literal;
 import org.apache.clerezza.rdf.core.MGraph;
@@ -26,6 +27,7 @@ import org.apache.clerezza.rdf.core.Plai
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.LockableMGraph;
+import org.apache.clerezza.rdf.core.access.LockableMGraphWrapper;
 import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
@@ -44,6 +46,8 @@ public class SameAsSmushTest {
     
     private final UriRef uriA = new UriRef("http://example.org/A");
     private final UriRef uriB = new UriRef("http://example.org/B");
+    private final UriRef uriC = new UriRef("http://example.org/C");
+    
     private final Literal lit = new PlainLiteralImpl("That's me (and you)");
 
     private MGraph sameAsStatements = new SimpleMGraph();
@@ -51,7 +55,7 @@ public class SameAsSmushTest {
         sameAsStatements.add(new TripleImpl(uriA, OWL.sameAs, uriB));
     }
     
-    private MGraph  dataGraph = new SimpleMGraph();
+    private LockableMGraph  dataGraph = new LockableMGraphWrapper(new SimpleMGraph());
     {
         dataGraph.add(new TripleImpl(uriA, FOAF.knows, uriB));
         dataGraph.add(new TripleImpl(uriB, RDFS.label, lit));
@@ -60,9 +64,19 @@ public class SameAsSmushTest {
 
     @Test
     public void simple()  {
+        SameAsSmusher smusher = new SameAsSmusher() {
+
+            @Override
+            protected UriRef getPreferedIri(Set<UriRef> uriRefs) {
+                if (!uriRefs.contains(uriA)) throw new RuntimeException("not the set we excpect");
+                if (!uriRefs.contains(uriB)) throw new RuntimeException("not the set we excpect");
+                return uriC;
+            }
+            
+        };
         Assert.assertEquals(3, dataGraph.size());
-        Smusher.sameAsSmush(dataGraph, sameAsStatements);
-        Assert.assertEquals(3, dataGraph.size());
+        smusher.smush(dataGraph, sameAsStatements, true);
+        Assert.assertEquals(4, dataGraph.size());
         Assert.assertTrue(dataGraph.filter(null, OWL.sameAs, null).hasNext());
         //exactly one statement with literal 
         Iterator<Triple> litStmts = dataGraph.filter(null, null, lit);
@@ -75,6 +89,7 @@ public class SameAsSmushTest {
         Assert.assertEquals(knowStmt.getSubject(), knowStmt.getObject());
         Assert.assertEquals(litStmt.getSubject(), knowStmt.getObject());
         Assert.assertEquals(litStmt.getSubject(), dataGraph.filter(null, OWL.sameAs, null).next().getObject());
+        Assert.assertEquals(knowStmt.getSubject(), uriC);
     }
 
 }



Mime
View raw message