}
});
}
// edit default version
SeState newState1 = session.issue(new Command<SeState>() {
@Override
public SeState execute(ISession session, SeConnection connection) throws SeException,
IOException {
SeObjectId defVersionStateId = defaultVersion.getStateId();
SeState defVersionState = new SeState(connection, defVersionStateId);
// create a new state as a child of the current one, the current
// one
// must be closed
if (defVersionState.isOpen()) {
defVersionState.close();
}
SeState newState1 = new SeState(connection);
newState1.create(defVersionState.getId());
return newState1;
}
});
session.startTransaction();
testData.insertIntoVersionedTable(session, newState1, versionedTable.getName(),
"name 1 state 1");
testData.insertIntoVersionedTable(session, newState1, versionedTable.getName(),
"name 2 state 1");
final SeObjectId parentStateId = newState1.getId();
session.close(newState1);
final SeState newState2 = session.issue(new Command<SeState>() {
@Override
public SeState execute(ISession session, SeConnection connection) throws SeException,
IOException {
SeState newState = new SeState(connection);
newState.create(parentStateId);
return newState;
}
});
testData.insertIntoVersionedTable(session, newState2, versionedTable.getName(),
"name 1 state 2");
session.issue(new Command<Void>() {
@Override
public Void execute(ISession session, SeConnection connection) throws SeException,
IOException {
// Change the version's state pointer to the last edit state.
defaultVersion.changeState(newState2.getId());
// Trim the state tree.
newState2.trimTree(parentStateId, newState2.getId());
return null;
}
});
session.commitTransaction();
// we edited the default version, lets query the default version and the
// new version and assert they have the correct feature count
final SeObjectId defaultVersionStateId = defaultVersion.getStateId();
SeState defVersionState = session.createState(defaultVersionStateId);
int defVersionCount = getTempTableCount(session, versionedTable.getName(), null, null,
defVersionState);
assertEquals(3, defVersionCount);
SeState newVersionState = session.createState(newVersion.getStateId());
int newVersionCount = getTempTableCount(session, versionedTable.getName(), null, null,
newVersionState);
assertEquals(0, newVersionCount);
}