]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphSupportListStatementsTest.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 / VirtualGraphSupportListStatementsTest.java
diff --git a/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphSupportListStatementsTest.java b/tests/org.simantics.db.tests/src/org/simantics/db/tests/api/support/virtualGraphSupport/VirtualGraphSupportListStatementsTest.java
new file mode 100644 (file)
index 0000000..80182d0
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.tests.api.support.virtualGraphSupport;
+
+import java.util.Collection;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+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.service.VirtualGraphSupport;
+import org.simantics.db.testing.base.ExistingDatabaseTest;
+
+public class VirtualGraphSupportListStatementsTest extends ExistingDatabaseTest {
+       
+       @Test
+       public void test() throws Exception{
+
+               // Create a new persistent resource
+               final Resource resource = getSession().syncRequest(new WriteResultRequest<Resource>() {
+                   @Override
+                   public Resource perform(WriteGraph g) throws DatabaseException {
+                       return g.newResource();
+                   }
+               });
+               
+               VirtualGraphSupport vgs = getSession().getService(VirtualGraphSupport.class);
+               VirtualGraph vg = vgs.getMemoryPersistent(UUID.randomUUID().toString());
+               
+               // Create some virtual graph
+               getSession().syncRequest(new WriteRequest(vg) {
+                   @Override
+                   public void perform(WriteGraph graph) throws DatabaseException {
+                       Resource virtual = graph.newResource();
+                       graph.claim(resource, L0.ConsistsOf, virtual);
+                       graph.claimLiteral(virtual, L0.HasName, "Name");
+                       
+                   }
+               });
+               
+               checkException();
+               
+               Collection<Statement> stms = vgs.listStatements(vg);
+        
+               assertEquals("Amount of statements.", stms.size(), 5);
+               
+       }
+
+}