use of org.apache.cayenne.access.MockDataNode in project cayenne by apache.
the class CayenneDataObjectFlattenedRelIT method testAddRemoveFlattenedRelationship2.
@Test
public void testAddRemoveFlattenedRelationship2() throws Exception {
create1Artist2ArtGroupDataSet();
Artist a1 = Cayenne.objectForPK(context, Artist.class, 33001);
SelectQuery q = new SelectQuery(ArtGroup.class);
List<?> results = context.performQuery(q);
assertEquals(2, results.size());
ArtGroup g1 = (ArtGroup) results.get(0);
ArtGroup g2 = (ArtGroup) results.get(1);
a1.addToGroupArray(g1);
a1.addToGroupArray(g2);
// test that there is no delete query issued when a flattened join is first
// added and then deleted AND there are some other changes (CAY-548)
a1.removeFromGroupArray(g1);
MockDataNode nodeWrapper = MockDataNode.interceptNode(runtime.getDataDomain(), runtime.getDataDomain().getDataNodes().iterator().next());
try {
context.commitChanges();
} finally {
nodeWrapper.stopInterceptNode();
}
assertEquals(1, nodeWrapper.getRunCount());
}
Aggregations