use of org.apache.cayenne.remote.ClientChannelServerDiffsListener1 in project cayenne by apache.
the class CayenneContextServerDiffsIT method testReturnDiffInPrePersist.
@Test
public void testReturnDiffInPrePersist() {
LifecycleCallbackRegistry callbackRegistry = clientServerChannel.getEntityResolver().getCallbackRegistry();
try {
callbackRegistry.addListener(LifecycleEvent.POST_ADD, MtTable1.class, new ClientChannelServerDiffsListener1(), "prePersist");
ClientMtTable1 o = context.newObject(ClientMtTable1.class);
o.setServerAttribute1("YY");
context.commitChanges();
assertFalse(o.getObjectId().isTemporary());
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
assertEquals("XXX", o.getGlobalAttribute1());
} finally {
callbackRegistry.clear();
}
}
use of org.apache.cayenne.remote.ClientChannelServerDiffsListener1 in project cayenne by apache.
the class CayenneContextServerDiffsIT method testReturnDiffServerArcChanges.
@Test
public void testReturnDiffServerArcChanges() {
LifecycleCallbackRegistry callbackRegistry = clientServerChannel.getEntityResolver().getCallbackRegistry();
try {
callbackRegistry.addListener(LifecycleEvent.POST_ADD, MtTable1.class, new ClientChannelServerDiffsListener1(), "prePersistAddRelationship");
ClientMtTable1 o = context.newObject(ClientMtTable1.class);
ClientMtTable2 o1 = context.newObject(ClientMtTable2.class);
o.addToTable2Array(o1);
context.commitChanges();
assertFalse(o.getObjectId().isTemporary());
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
assertEquals(2, o.getTable2Array().size());
} finally {
callbackRegistry.clear();
}
}
use of org.apache.cayenne.remote.ClientChannelServerDiffsListener1 in project cayenne by apache.
the class CayenneContextServerDiffsIT method testReturnDiffInPreUpdate.
@Test
public void testReturnDiffInPreUpdate() {
LifecycleCallbackRegistry callbackRegistry = clientServerChannel.getEntityResolver().getCallbackRegistry();
try {
callbackRegistry.addListener(LifecycleEvent.PRE_UPDATE, MtTable1.class, new ClientChannelServerDiffsListener1(), "preUpdate");
ClientMtTable1 o = context.newObject(ClientMtTable1.class);
o.setServerAttribute1("YY");
context.commitChanges();
assertNull(o.getGlobalAttribute1());
o.setServerAttribute1("XX");
context.commitChanges();
assertFalse(o.getObjectId().isTemporary());
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
assertEquals("111", o.getGlobalAttribute1());
} finally {
callbackRegistry.clear();
}
}
use of org.apache.cayenne.remote.ClientChannelServerDiffsListener1 in project cayenne by apache.
the class CayenneContextServerDiffsIT method testReturnDiffClientArcChanges.
@Test
public void testReturnDiffClientArcChanges() {
LifecycleCallbackRegistry callbackRegistry = clientServerChannel.getEntityResolver().getCallbackRegistry();
try {
callbackRegistry.addListener(LifecycleEvent.POST_ADD, MtTable1.class, new ClientChannelServerDiffsListener1(), "prePersist");
ClientMtTable1 o = context.newObject(ClientMtTable1.class);
ClientMtTable2 o1 = context.newObject(ClientMtTable2.class);
o.addToTable2Array(o1);
context.commitChanges();
assertFalse(o.getObjectId().isTemporary());
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
assertEquals("XXX", o.getGlobalAttribute1());
} finally {
callbackRegistry.clear();
}
}
Aggregations