1 package org.simantics.db.tests.api.support.clusterControl;
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;
15 public class ObjectsWithNoClusterWithCachedRelationInfo extends ExistingDatabaseTest {
18 public void test() throws DatabaseException {
20 Session session = getSession();
22 final Layer0 L0 = Layer0.getInstance(session);
24 // Create resource in new cluster (not 1)
25 final Resource res = session.syncRequest(new WriteResultRequest<Resource>() {
28 public Resource perform(WriteGraph graph) throws DatabaseException {
30 Resource res = graph.newResource();
31 graph.claim(res, L0.HasName, L0.NameOf, res);
38 // Cache RelationInfo for HasName
39 session.syncRequest(new PossibleObject(L0.Entity, L0.HasName), new ListenerAdapter<Resource>());
42 ClusterControl support = getSession().getService(ClusterControl.class);
43 support.collectClusters(Integer.MAX_VALUE);
45 // Request objects for res, now relationinfo is in cache and res has no cluster
46 session.syncRequest(new PossibleObject(res, L0.HasName));