@Test public void testPersistenceCache() { Store store = new Store(1, "Food Bazaar, Noida"); store.addCounter(new BillingCounter(1, "A")); store.addCounter(new BillingCounter(2, "B")); store.addCounter(new BillingCounter(3, "C")); ObjectGraph graph = graphBuilder.getObjectGraph(store, null); pc.getMainCache().addGraphToCache(graph, pc); Assert.assertNotNull(pc.getMainCache()); Assert.assertEquals(1, pc.getMainCache().getHeadNodes().size()); PersistenceDelegator pd = new PersistenceDelegator(emfImpl.getKunderaMetadataInstance(), pc); Node headNode = pc.getMainCache().getNodeFromCache(ObjectGraphUtils.getNodeId("1", Store.class), pd); Assert.assertNotNull(headNode); Assert.assertNull(headNode.getParents()); Assert.assertEquals(3, headNode.getChildren().size()); Assert.assertEquals(4, pc.getMainCache().size()); }
@Test public void testFlashStockForStore() { FlushManager flushManager = new FlushManager(); Store store = new Store(1, "Food Bazaar, Noida"); store.addCounter(new BillingCounter(1, "A")); store.addCounter(new BillingCounter(2, "B")); store.addCounter(new BillingCounter(3, "C")); ObjectGraph graph = graphBuilder.getObjectGraph(store, null); pc.getMainCache().addGraphToCache(graph, pc); Assert.assertNotNull(pc.getMainCache()); Assert.assertEquals(1, pc.getMainCache().getHeadNodes().size()); PersistenceDelegator pd = new PersistenceDelegator(emfImpl.getKunderaMetadataInstance(), pc); Node headNode = pc.getMainCache().getNodeFromCache(ObjectGraphUtils.getNodeId("1", Store.class), pd); Assert.assertNotNull(headNode); Assert.assertNull(headNode.getParents()); Assert.assertEquals(3, headNode.getChildren().size()); Assert.assertEquals(4, pc.getMainCache().size()); markAllNodeAsDirty(); flushManager.buildFlushStack(headNode, EventType.INSERT); Deque<Node> fs = flushManager.getFlushStack(); Assert.assertEquals(4, fs.size()); }
@Test public void test_multi_1_1_1_1() { FlushManager flushManager = new FlushManager(); PhotographerBi_1_1_1_1 a = new PhotographerBi_1_1_1_1(); a.setPhotographerId(1); AlbumBi_1_1_1_1 b = new AlbumBi_1_1_1_1(); b.setAlbumId("b1"); PhotoBi_1_1_1_1 c = new PhotoBi_1_1_1_1(); c.setPhotoId("c1"); b.setPhotographer(a); b.setPhoto(c); ObjectGraph graph = graphBuilder.getObjectGraph(b, null); pc.getMainCache().addGraphToCache(graph, pc); markAllNodeAsDirty(); flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT); Deque<Node> fs = flushManager.getFlushStack(); Assert.assertEquals(2, fs.size()); }
ObjectGraph graphb3 = graphBuilder.getObjectGraph(b3, null); pc.getMainCache().addGraphToCache(graph, pc); pc.getMainCache().addGraphToCache(graphb2, pc); pc.getMainCache().addGraphToCache(graphb3, pc);
@Test public void test_1_1_1_1() { FlushManager flushManager = new FlushManager(); PhotographerUni_1_1_1_1 a = new PhotographerUni_1_1_1_1(); a.setPhotographerId(1); AlbumUni_1_1_1_1 b = new AlbumUni_1_1_1_1(); b.setAlbumId("b1"); PhotoUni_1_1_1_1 c = new PhotoUni_1_1_1_1(); c.setPhotoId("c1"); a.setAlbum(b); b.setPhoto(c); ObjectGraph graph = graphBuilder.getObjectGraph(a, null); pc.getMainCache().addGraphToCache(graph, pc); PersistenceDelegator pd = new PersistenceDelegator(emfImpl.getKunderaMetadataInstance(), pc); Node headNode = pc.getMainCache() .getNodeFromCache(ObjectGraphUtils.getNodeId("c1", PhotoUni_1_1_1_1.class), pd); markAllNodeAsDirty(); flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT); Deque<Node> fs = flushManager.getFlushStack(); Assert.assertEquals(3, fs.size()); }
ObjectGraph graph3 = graphBuilder.getObjectGraph(a3, null); pc.getMainCache().addGraphToCache(graph1, pc); pc.getMainCache().addGraphToCache(graph2, pc); markAllNodeAsDirty(); flushManager = new FlushManager(); pc.getMainCache().addGraphToCache(graph3, pc); markAllNodeAsDirty(); flushManager = new FlushManager();
@Test public void test_1_1_1_M() { FlushManager flushManager = new FlushManager(); PhotographerUni_1_1_1_M a = new PhotographerUni_1_1_1_M(); a.setPhotographerId(1); AlbumUni_1_1_1_M b = new AlbumUni_1_1_1_M(); b.setAlbumId("b1"); PhotoUni_1_1_1_M c1 = new PhotoUni_1_1_1_M(); c1.setPhotoId("c1"); PhotoUni_1_1_1_M c2 = new PhotoUni_1_1_1_M(); c2.setPhotoId("c2"); PhotoUni_1_1_1_M c3 = new PhotoUni_1_1_1_M(); c3.setPhotoId("c3"); a.setAlbum(b); b.addPhoto(c1); b.addPhoto(c2); b.addPhoto(c3); ObjectGraph graph = graphBuilder.getObjectGraph(a, null); pc.getMainCache().addGraphToCache(graph, pc); markAllNodeAsDirty(); flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT); Deque<Node> fs = flushManager.getFlushStack(); Assert.assertEquals(5, fs.size()); }
pc.getMainCache().addGraphToCache(graph1, pc); a2.addAlbum(b3); ObjectGraph graph2 = graphBuilder.getObjectGraph(a2, null); pc.getMainCache().addGraphToCache(graph2, pc); markAllNodeAsDirty(); flushManager = new FlushManager();
pc.getMainCache().addGraphToCache(graph1, pc); a2.addAlbum(b3); ObjectGraph graph2 = graphBuilder.getObjectGraph(a2, null); pc.getMainCache().addGraphToCache(graph2, pc);
@Test public void test_1_M_M_M() { FlushManager flushManager = new FlushManager(); PhotographerUni_1_M_M_M a = new PhotographerUni_1_M_M_M(); a.setPhotographerId(1); AlbumUni_1_M_M_M b1 = new AlbumUni_1_M_M_M(); b1.setAlbumId("b1"); AlbumUni_1_M_M_M b2 = new AlbumUni_1_M_M_M(); b2.setAlbumId("b2"); PhotoUni_1_M_M_M c1 = new PhotoUni_1_M_M_M(); c1.setPhotoId("c1"); PhotoUni_1_M_M_M c2 = new PhotoUni_1_M_M_M(); c2.setPhotoId("c2"); PhotoUni_1_M_M_M c3 = new PhotoUni_1_M_M_M(); c3.setPhotoId("c3"); b1.addPhoto(c1); b1.addPhoto(c2); b2.addPhoto(c2); b2.addPhoto(c3); a.addAlbum(b1); a.addAlbum(b2); ObjectGraph graph = graphBuilder.getObjectGraph(a, null); pc.getMainCache().addGraphToCache(graph, pc); markAllNodeAsDirty(); flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT); Deque<Node> fs = flushManager.getFlushStack(); Assert.assertEquals(3, fs.size()); }
pc.getMainCache().addGraphToCache(graph, pc);