]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 package org.simantics.db.tests.api.support.virtualGraphSupport;
2
3 import java.util.UUID;
4
5 import org.simantics.db.Resource;
6 import org.simantics.db.VirtualGraph;
7 import org.simantics.db.WriteGraph;
8 import org.simantics.db.common.request.WriteResultRequest;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.service.VirtualGraphSupport;
11 import org.simantics.db.testing.base.WriteReadTest;
12
13 public class VirtualGraphTest6 extends WriteReadTest {
14     
15     @Override
16     protected void write(WriteGraph graph) throws DatabaseException {
17         
18         VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);
19         VirtualGraph virt = support.getMemoryPersistent(UUID.randomUUID().toString());
20         
21         Resource other = graph.syncRequest(new WriteResultRequest<Resource>(virt) {
22
23             @Override
24             public Resource perform(WriteGraph graph) throws DatabaseException {
25                 Resource other = graph.newResource();
26                 if (DEBUG)
27                     System.err.println("other=" + other);
28                 graph.claim(written, L0.ConsistsOf, L0.PartOf, other);
29                 return other;
30             }
31             
32         });
33
34         Resource single = graph.getSingleObject(written, L0.ConsistsOf);
35         if (DEBUG)
36             System.err.println("single=" + single);
37         assertNotNull(single);
38         assertTrue(single.equals(other));
39         
40     }
41
42 }