use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class CayenneContextDeletionIT method testDeletion.
@Test
public void testDeletion() {
ClientMtTable1 object = clientContext.newObject(ClientMtTable1.class);
clientContext.commitChanges();
clientContext.deleteObjects(object);
// now check that the object is unregistered
clientContext.commitChanges();
assertNull(clientContext.getGraphManager().getNode(object.getObjectId()));
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class ClientChannelServerDiffsIT method testReturnDiffClientArcChanges.
@Test
public void testReturnDiffClientArcChanges() {
final NoopGraphChangeHandler diffReader = new NoopGraphChangeHandler();
ClientChannel channel = new ClientChannel(connection, false, new MockEventManager(), false) {
@Override
public GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType) {
GraphDiff serverDiff = super.onSync(originatingContext, changes, syncType);
assertNotNull(serverDiff);
serverDiff.apply(diffReader);
return serverDiff;
}
};
CayenneContext context = new CayenneContext(channel);
ClientMtTable1 o = context.newObject(ClientMtTable1.class);
ClientMtTable2 o2 = context.newObject(ClientMtTable2.class);
o.addToTable2Array(o2);
context.commitChanges();
assertEquals(2, diffReader.size);
diffReader.reset();
ClientMtTable2 o3 = context.newObject(ClientMtTable2.class);
o3.setTable1(o);
context.commitChanges();
assertEquals(1, diffReader.size);
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class NestedObjectContextLocalIT method testLocalCacheStaysLocal.
@Test
public void testLocalCacheStaysLocal() {
SelectQuery<ClientMtTable1> query = new SelectQuery<ClientMtTable1>(ClientMtTable1.class);
query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
BaseContext child1 = (BaseContext) runtime.newContext(clientContext);
assertNull(child1.getQueryCache().get(query.getMetaData(child1.getEntityResolver())));
assertNull(clientContext.getQueryCache().get(query.getMetaData(clientContext.getEntityResolver())));
List<?> results = child1.performQuery(query);
assertSame(results, child1.getQueryCache().get(query.getMetaData(child1.getEntityResolver())));
assertNull(clientContext.getQueryCache().get(query.getMetaData(clientContext.getEntityResolver())));
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class NestedObjectContextParentEventsIT method testParentUpdatedId.
@Test
public void testParentUpdatedId() throws Exception {
ObjectContext child = runtime.newContext(clientContext);
ClientMtTable1 ac = child.newObject(ClientMtTable1.class);
ac.setGlobalAttribute1("X");
child.commitChangesToParent();
ClientMtTable1 ap = (ClientMtTable1) clientContext.getGraphManager().getNode(ac.getObjectId());
assertNotNull(ap);
assertTrue(ap.getObjectId().isTemporary());
clientContext.commitChanges();
assertFalse(ap.getObjectId().isTemporary());
assertEquals(ap.getObjectId(), ac.getObjectId());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class NestedObjectContextPeerEventsIT method testPeerObjectUpdatedSimpleProperty.
@Test
public void testPeerObjectUpdatedSimpleProperty() throws Exception {
ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class);
a.setGlobalAttribute1("X");
clientContext.commitChanges();
ObjectContext peer1 = runtime.newContext(clientContext);
ClientMtTable1 a1 = peer1.localObject(a);
ObjectContext peer2 = runtime.newContext(clientContext);
ClientMtTable1 a2 = peer2.localObject(a);
a1.setGlobalAttribute1("Y");
assertEquals("X", a2.getGlobalAttribute1());
peer1.commitChangesToParent();
assertEquals("Y", a2.getGlobalAttribute1());
assertFalse("Peer data context became dirty on event processing", peer2.hasChanges());
}
Aggregations