*/
public class ContextStateRecorderTest extends TestCase {
public void testDirtyNodesInState() {
GraphManager map = new MockGraphManager();
ObjectContextStateLog recorder = new ObjectContextStateLog(map);
// check for null collections
assertNotNull(recorder.dirtyNodes(PersistenceState.MODIFIED));
assertNotNull(recorder.dirtyNodes(PersistenceState.COMMITTED));
assertNotNull(recorder.dirtyNodes(PersistenceState.DELETED));
assertNotNull(recorder.dirtyNodes(PersistenceState.NEW));
assertNotNull(recorder.dirtyNodes(PersistenceState.TRANSIENT));
assertNotNull(recorder.dirtyNodes(PersistenceState.HOLLOW));
assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.NEW).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.TRANSIENT).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.HOLLOW).isEmpty());
MockPersistentObject modified = new MockPersistentObject();
modified.setObjectId(new ObjectId("MockPersistentObject", "key", "value1"));
modified.setPersistenceState(PersistenceState.MODIFIED);
map.registerNode(modified.getObjectId(), modified);
recorder.nodePropertyChanged(modified.getObjectId(), "a", "b", "c");
assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).contains(modified));
assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.NEW).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.TRANSIENT).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.HOLLOW).isEmpty());
MockPersistentObject deleted = new MockPersistentObject();
deleted.setObjectId(new ObjectId("MockPersistentObject", "key", "value2"));
deleted.setPersistenceState(PersistenceState.DELETED);
map.registerNode(deleted.getObjectId(), deleted);
recorder.nodeRemoved(deleted.getObjectId());
assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).contains(modified));
assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).contains(deleted));