]> gerrit.simantics Code Review - simantics/platform.git/blob
0596f765873630e4bfda2f322385b91aa94ec272
[simantics/platform.git] /
1 package org.simantics.db.tests.api.support.clusterControl;
2
3 import org.junit.Test;
4 import org.simantics.db.Resource;
5 import org.simantics.db.Session;
6 import org.simantics.db.WriteGraph;
7 import org.simantics.db.common.primitiverequest.PossibleObject;
8 import org.simantics.db.common.procedure.adapter.ListenerAdapter;
9 import org.simantics.db.common.request.WriteResultRequest;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.service.ClusterControl;
12 import org.simantics.db.testing.base.ExistingDatabaseTest;
13 import org.simantics.layer0.Layer0;
14
15 public class ObjectsWithNoClusterWithCachedRelationInfo extends ExistingDatabaseTest {
16     
17     @Test
18     public void test() throws DatabaseException {
19         
20         Session session = getSession();
21         
22                 final Layer0 L0 = Layer0.getInstance(session);
23                 
24                 // Create resource in new cluster (not 1)
25         final Resource res = session.syncRequest(new WriteResultRequest<Resource>() {
26
27                         @Override
28                         public Resource perform(WriteGraph graph) throws DatabaseException {
29
30                                 Resource res = graph.newResource();
31                                 graph.claim(res, L0.HasName, L0.NameOf, res);
32                                 return res;
33                                 
34                         }
35                 
36         });
37         
38         // Cache RelationInfo for HasName
39         session.syncRequest(new PossibleObject(L0.Entity, L0.HasName), new ListenerAdapter<Resource>());
40
41         // Flush clusters
42                 ClusterControl support = getSession().getService(ClusterControl.class);
43                 support.collectClusters(Integer.MAX_VALUE);
44                 
45                 // Request objects for res, now relationinfo is in cache and res has no cluster
46         session.syncRequest(new PossibleObject(res, L0.HasName));
47                 
48     }
49 }