1 package org.simantics.db.tests.api.support.managementSupport;
3 import java.util.Collection;
6 import org.simantics.db.ChangeSet;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.WriteGraph;
9 import org.simantics.db.common.request.ReadRequest;
10 import org.simantics.db.common.request.WriteRequest;
11 import org.simantics.db.exception.DatabaseException;
12 import org.simantics.db.service.ManagementSupport;
13 import org.simantics.db.testing.base.ExistingDatabaseTest;
15 public class FetchChangeSetsTest extends ExistingDatabaseTest {
16 // static final boolean DEBUG = true;
17 static final boolean VERBOSE = false;
19 public void test() throws DatabaseException {
20 final ManagementSupport ms = getSession().getService(ManagementSupport.class);
21 final long startId = 1;
22 getSession().syncRequest(new WriteRequest() {
24 public void perform(WriteGraph g) throws DatabaseException {
28 final long endId = ms.getHeadRevisionId();
29 assertTrue(endId > 0);
30 getSession().syncRequest(new ReadRequest() {
32 public void run(ReadGraph g) throws DatabaseException {
33 long id = ms.getHeadRevisionId();
34 assertTrue(endId == id);
35 Collection<ChangeSet> css = ms.fetchChangeSets(g, endId, endId);
37 assertEquals("Failed to get change sets.", size, css.size());
39 printDebug(css, endId);
42 getSession().syncRequest(new ReadRequest() {
44 public void run(ReadGraph g) throws DatabaseException {
45 long id = ms.getHeadRevisionId();
46 assertTrue(endId == id);
47 Collection<ChangeSet> css = ms.fetchChangeSets(g, startId, endId);
48 // Can't be sure that old change sets are preserved.
49 assertTrue("Failed to get change sets.", css.size() >= 1);
51 printDebug(css, startId);
55 static void printDebug(Collection<ChangeSet> css, long startId) {
59 for (ChangeSet cs: css) {
60 System.out.println("cs=" + id);
62 System.out.println(cs.toString());