use of org.apache.cayenne.testdo.mt.ClientMtTable1 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.testdo.mt.ClientMtTable1 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();
}
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextWithDataContextIT method testCreateFault.
@Test
public void testCreateFault() throws Exception {
tMtTable1.insert(1, "g1", "s1");
ObjectId id = new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 1);
Object fault = clientContext.createFault(id);
assertTrue(fault instanceof ClientMtTable1);
ClientMtTable1 o = (ClientMtTable1) fault;
assertEquals(PersistenceState.HOLLOW, o.getPersistenceState());
assertSame(clientContext, o.getObjectContext());
assertNull(o.getGlobalAttribute1Direct());
// make sure we haven't tripped the fault yet
assertEquals(PersistenceState.HOLLOW, o.getPersistenceState());
// try tripping fault
assertEquals("g1", o.getGlobalAttribute1());
assertEquals(PersistenceState.COMMITTED, o.getPersistenceState());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class PersistentObjectHolderTest method testSetInitialValue.
@Test
public void testSetInitialValue() {
ObjectContext context = mock(ObjectContext.class);
ClientMtTable2 o = new ClientMtTable2();
o.setPersistenceState(PersistenceState.COMMITTED);
o.setObjectContext(context);
PersistentObjectHolder holder = new PersistentObjectHolder(o, ClientMtTable2.TABLE1_PROPERTY);
assertTrue(holder.isFault());
ClientMtTable1 o1 = new ClientMtTable1();
o1.setObjectContext(context);
holder.setValueDirectly(o1);
assertFalse(holder.isFault());
assertSame(o1, holder.value);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextWithDataContextIT method testPrefetchingToManyEmpty.
@Test
public void testPrefetchingToManyEmpty() throws Exception {
createTwoMtTable1sAnd2sDataSet();
SelectQuery q = new SelectQuery(ClientMtTable1.class);
q.addOrdering(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, SortOrder.ASCENDING);
q.addPrefetch(ClientMtTable1.TABLE2ARRAY_PROPERTY);
final List<ClientMtTable1> results = clientContext.performQuery(q);
clientServerInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
public void execute() {
ClientMtTable1 o2 = results.get(1);
assertEquals(PersistenceState.COMMITTED, o2.getPersistenceState());
assertSame(clientContext, o2.getObjectContext());
List<ClientMtTable2> children2 = o2.getTable2Array();
assertFalse(((ValueHolder) children2).isFault());
assertEquals(0, children2.size());
}
});
}
Aggregations