}
@Test
public void test_M_1_1_M()
{
FlushManager flushManager = new FlushManager();
PhotographerUni_M_1_1_M a1 = new PhotographerUni_M_1_1_M();
a1.setPhotographerId(1);
PhotographerUni_M_1_1_M a2 = new PhotographerUni_M_1_1_M();
a2.setPhotographerId(2);
PhotographerUni_M_1_1_M a3 = new PhotographerUni_M_1_1_M();
a3.setPhotographerId(3);
AlbumUni_M_1_1_M b = new AlbumUni_M_1_1_M();
b.setAlbumId("b");
PhotoUni_M_1_1_M c1 = new PhotoUni_M_1_1_M();
c1.setPhotoId("c1");
PhotoUni_M_1_1_M c2 = new PhotoUni_M_1_1_M();
c2.setPhotoId("c2");
PhotoUni_M_1_1_M c3 = new PhotoUni_M_1_1_M();
c3.setPhotoId("c3");
b.addPhoto(c1);
b.addPhoto(c2);
b.addPhoto(c3);
a1.setAlbum(b);
ObjectGraph graph1 = graphBuilder.getObjectGraph(a1, null);
ObjectGraph graph2 = graphBuilder.getObjectGraph(a2, null);
ObjectGraph graph3 = graphBuilder.getObjectGraph(a3, null);
pc.getMainCache().addGraphToCache(graph1, pc);
markAllNodeAsDirty();
flushManager.buildFlushStack(graph1.getHeadNode(), EventType.INSERT);
Deque<Node> fs = flushManager.getFlushStack();
Assert.assertEquals(5, fs.size());
flushManager.clearFlushStack();
a2.setAlbum(b);
pc.getMainCache().addGraphToCache(graph2, pc);
markAllNodeAsDirty();
flushManager = new FlushManager();
flushManager.buildFlushStack(graph2.getHeadNode(), EventType.INSERT);
fs = flushManager.getFlushStack();
Assert.assertEquals(1, fs.size());
flushManager.clearFlushStack();
a3.setAlbum(b);
pc.getMainCache().addGraphToCache(graph3, pc);
markAllNodeAsDirty();
flushManager = new FlushManager();
flushManager.buildFlushStack(graph3.getHeadNode(), EventType.INSERT);
fs = flushManager.getFlushStack();
Assert.assertEquals(1, fs.size());
flushManager.clearFlushStack();
}