use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextMergeHandlerIT method testNodePropertyChanged.
@Test
public void testNodePropertyChanged() {
ClientMtTable1 o1 = context.newObject(ClientMtTable1.class);
CayenneContextMergeHandler handler = new CayenneContextMergeHandler(context);
assertNull(o1.getGlobalAttribute1Direct());
handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, null, "abc");
assertEquals("abc", o1.getGlobalAttribute1Direct());
handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "abc", "xyz");
assertEquals("xyz", o1.getGlobalAttribute1Direct());
// block if old value is different
handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "123", "mnk");
assertEquals("xyz", o1.getGlobalAttribute1Direct());
handler.nodePropertyChanged(o1.getObjectId(), ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "xyz", null);
assertNull(o1.getGlobalAttribute1Direct());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextPaginatedListCachingIT method testLocalCache.
@Test
public void testLocalCache() throws Exception {
createSevenMtTable1sDataSet();
SelectQuery query = new SelectQuery(ClientMtTable1.class);
query.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
query.setPageSize(3);
query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
List<ClientMtTable1> result1 = context.performQuery(query);
assertEquals(7, result1.size());
// ensure we can resolve all objects without a failure...
for (ClientMtTable1 x : result1) {
x.getGlobalAttribute1();
}
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextRelationshipsIT method testLostUncommittedToOneModifications_Client.
@Test
public void testLostUncommittedToOneModifications_Client() throws Exception {
tMtTable1.insert(1, "G1", "S1");
tMtTable1.insert(2, "G2", "S2");
tMtTable2.insert(33, 1, "GX");
ClientMtTable2 o = Cayenne.objectForPK(context, ClientMtTable2.class, 33);
ClientMtTable1 r2 = Cayenne.objectForPK(context, ClientMtTable1.class, 2);
ClientMtTable1 r1 = o.getTable1();
o.setTable1(r2);
assertSame(r2, o.getTable1());
// see CAY-1757 - this used to reset our changes
assertFalse(r1.getTable2Array().contains(o));
assertSame(r2, o.getTable1());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 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.testdo.mt.ClientMtTable1 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();
}
}
Aggregations