]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/PersistentSetValueIntoVirtualResourceTest.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 / PersistentSetValueIntoVirtualResourceTest.java
diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/PersistentSetValueIntoVirtualResourceTest.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/PersistentSetValueIntoVirtualResourceTest.java
new file mode 100644 (file)
index 0000000..4acace9
--- /dev/null
@@ -0,0 +1,51 @@
+package org.simantics.db.tests.api.support.virtualGraphSupport;
+
+import java.util.UUID;
+
+import org.junit.Test;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.common.request.WriteResultRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.ServiceException;
+import org.simantics.db.service.VirtualGraphSupport;
+import org.simantics.db.testing.base.ExistingDatabaseTest;
+
+public class PersistentSetValueIntoVirtualResourceTest extends ExistingDatabaseTest {
+    
+       @Test
+    public void test() throws Exception{
+
+        VirtualGraphSupport vgs = getSession().getService(VirtualGraphSupport.class);
+        VirtualGraph vg = vgs.getMemoryPersistent(UUID.randomUUID().toString());
+        
+        final Resource virtual = getSession().syncRequest(new WriteResultRequest<Resource>(vg) {
+            @Override
+            public Resource perform(WriteGraph graph) throws DatabaseException {
+                return graph.newResource();
+            }
+        });
+        
+        checkException();
+
+        try {
+            getSession().syncRequest(new WriteRequest() {
+                @Override
+                public void perform(WriteGraph graph) throws DatabaseException {
+                    graph.claimValue(virtual, "Name", Bindings.STRING);
+                }
+            });
+        } catch (ServiceException e) {
+            if (DEBUG)
+                e.printStackTrace();
+            return;
+        }
+        
+        fail("Should throw.");
+        
+    }
+
+}