use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectStore method nodeCreated.
/**
* @since 1.2
*/
@Override
public void nodeCreated(Object nodeId) {
NodeDiff diff = new NodeCreateOperation(nodeId);
if (lifecycleEventInducedChanges != null) {
registerLifecycleEventInducedChange(diff);
}
registerDiff(nodeId, diff);
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class CayenneContextGraphManager method nodeCreated.
@Override
public synchronized void nodeCreated(Object nodeId) {
stateLog.nodeCreated(nodeId);
processChange(new NodeCreateOperation(nodeId));
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectContextChangeLogTest method testGetDiffsSerializable.
@Test
public void testGetDiffsSerializable() throws Exception {
ObjectContextChangeLog recorder = new ObjectContextChangeLog();
recorder.addOperation(new NodeCreateOperation(new ObjectId("test")));
CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
Object clone = Util.cloneViaSerialization(diff);
assertNotNull(clone);
assertTrue(clone instanceof CompoundDiff);
CompoundDiff d1 = (CompoundDiff) clone;
assertEquals(1, d1.getDiffs().size());
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectContextChangeLogTest method testReset.
@Test
public void testReset() {
ObjectContextChangeLog recorder = new ObjectContextChangeLog();
assertNotNull(recorder.getDiffs());
assertTrue(recorder.getDiffs().isNoop());
recorder.addOperation(new NodeCreateOperation(new Object()));
assertNotNull(recorder.getDiffs());
assertFalse(recorder.getDiffs().isNoop());
recorder.reset();
assertNotNull(recorder.getDiffs());
assertTrue(recorder.getDiffs().isNoop());
// now test that a diff stored before "clear" is not affected by 'clear'
recorder.addOperation(new NodeCreateOperation(new Object()));
GraphDiff diff = recorder.getDiffs();
assertFalse(diff.isNoop());
recorder.reset();
assertFalse(diff.isNoop());
}
use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.
the class ObjectContextChangeLogTest method testGetDiffs.
@Test
public void testGetDiffs() {
// assert that after returning, the diffs array won't get modified by
// operation
// recorder
ObjectContextChangeLog recorder = new ObjectContextChangeLog();
recorder.addOperation(new NodeCreateOperation(new Object()));
CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
assertEquals(1, diff.getDiffs().size());
recorder.addOperation(new NodeCreateOperation(new Object()));
assertEquals(1, diff.getDiffs().size());
CompoundDiff diff2 = (CompoundDiff) recorder.getDiffs();
assertEquals(2, diff2.getDiffs().size());
}
Aggregations