]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphTest6.java
Added missing org.simantics.db.{tests,testing} plug-ins.
[simantics/platform.git] / tests / org.simantics.db.tests / src / org / simantics / db / tests / api / support / virtualGraphSupport / VirtualGraphTest6.java
diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphTest6.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphTest6.java
new file mode 100644 (file)
index 0000000..6b0e618
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.db.tests.api.support.virtualGraphSupport;
+
+import java.util.UUID;
+
+import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteResultRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.VirtualGraphSupport;
+import org.simantics.db.testing.base.WriteReadTest;
+
+public class VirtualGraphTest6 extends WriteReadTest {
+    
+    @Override
+    protected void write(WriteGraph graph) throws DatabaseException {
+        
+        VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);
+        VirtualGraph virt = support.getMemoryPersistent(UUID.randomUUID().toString());
+        
+        Resource other = graph.syncRequest(new WriteResultRequest<Resource>(virt) {
+
+            @Override
+            public Resource perform(WriteGraph graph) throws DatabaseException {
+                Resource other = graph.newResource();
+                if (DEBUG)
+                    System.err.println("other=" + other);
+                graph.claim(written, L0.ConsistsOf, L0.PartOf, other);
+                return other;
+            }
+            
+        });
+
+        Resource single = graph.getSingleObject(written, L0.ConsistsOf);
+        if (DEBUG)
+            System.err.println("single=" + single);
+        assertNotNull(single);
+        assertTrue(single.equals(other));
+        
+    }
+
+}
\ No newline at end of file