use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class NestedObjectContextPeerEventsIT method testPeerObjectUpdatedToManyRelationship.
@Test
public void testPeerObjectUpdatedToManyRelationship() throws Exception {
ClientMtTable1 a = clientContext.newObject(ClientMtTable1.class);
a.setGlobalAttribute1("X");
ClientMtTable2 px = clientContext.newObject(ClientMtTable2.class);
px.setTable1(a);
px.setGlobalAttribute("PX");
ClientMtTable2 py = clientContext.newObject(ClientMtTable2.class);
py.setGlobalAttribute("PY");
clientContext.commitChanges();
ObjectContext peer1 = runtime.newContext(clientContext);
ClientMtTable2 py1 = peer1.localObject(py);
ClientMtTable1 a1 = peer1.localObject(a);
ObjectContext peer2 = runtime.newContext(clientContext);
ClientMtTable2 py2 = peer2.localObject(py);
ClientMtTable1 a2 = peer2.localObject(a);
a1.addToTable2Array(py1);
assertEquals(1, a2.getTable2Array().size());
assertFalse(a2.getTable2Array().contains(py2));
peer1.commitChangesToParent();
assertEquals(2, a2.getTable2Array().size());
assertTrue(a2.getTable2Array().contains(py2));
assertFalse("Peer data context became dirty on event processing", peer2.hasChanges());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class RelationshipChangeIT method testNullify.
@Test
public void testNullify() {
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class);
o2.setTable1(o1);
assertEquals(1, o1.getTable2Array().size());
clientContext.commitChanges();
o2.setTable1(null);
assertEquals(0, o1.getTable2Array().size());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class RemoteIncrementalFaultListIT method testLastIndexOf.
@Test
public void testLastIndexOf() throws Exception {
prepareList(6);
Expression qual = ExpressionFactory.matchExp(ClientMtTable1.GLOBAL_ATTRIBUTE1_PROPERTY, "g20");
SelectQuery<ClientMtTable1> query = new SelectQuery<ClientMtTable1>(ClientMtTable1.class, qual);
List<?> objects = list.context.performQuery(query);
assertEquals(1, objects.size());
ClientMtTable1 row = (ClientMtTable1) objects.get(0);
assertEquals(19, list.lastIndexOf(row));
assertEquals(-1, list.lastIndexOf(list.context.newObject(ClientMtTable1.class)));
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class RemoteRollbackIT method testRollbackRelationshipModification.
@Test
public void testRollbackRelationshipModification() {
String o1Name = "relationshipModClientMtTable1";
String o2Title = "relationshipTestClientMtTable2";
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1(o1Name);
ClientMtTable2 o2 = clientContext.newObject(ClientMtTable2.class);
o2.setGlobalAttribute(o2Title);
o2.setTable1(o1);
assertEquals(1, o1.getTable2Array().size());
clientContext.commitChanges();
assertEquals(1, o1.getTable2Array().size());
o2.setTable1(null);
assertEquals(0, o1.getTable2Array().size());
clientContext.rollbackChanges();
assertEquals(1, o1.getTable2Array().size());
assertEquals(o1, o2.getTable1());
}
use of org.apache.cayenne.testdo.mt.ClientMtTable1 in project cayenne by apache.
the class RemoteRollbackIT method testRollbackModifiedObject.
@Test
public void testRollbackModifiedObject() {
String o1Name = "initialTestClientMtTable1";
ClientMtTable1 o1 = clientContext.newObject(ClientMtTable1.class);
o1.setGlobalAttribute1(o1Name);
clientContext.commitChanges();
o1.setGlobalAttribute1("a new value");
clientContext.rollbackChanges();
// Make sure the inmemory changes have been rolled back
assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
assertEquals(o1Name, o1.getGlobalAttribute1());
}
Aggregations