Examples of FlushManager


Examples of com.impetus.kundera.persistence.context.FlushManager

    @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());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @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());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @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());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.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());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @Test
    public void test_1_1_M_1()
    {
        FlushManager flushManager = new FlushManager();
        PhotographerUni_1_1_M_1 a = new PhotographerUni_1_1_M_1();
        a.setPhotographerId(1);
        AlbumUni_1_1_M_1 b1 = new AlbumUni_1_1_M_1();
        b1.setAlbumId("b1");
        AlbumUni_1_1_M_1 b2 = new AlbumUni_1_1_M_1();
        b2.setAlbumId("b2");
        AlbumUni_1_1_M_1 b3 = new AlbumUni_1_1_M_1();
        b3.setAlbumId("b3");

        PhotoUni_1_1_M_1 c = new PhotoUni_1_1_M_1();
        c.setPhotoId("c");
        a.setAlbum(b1);
        b1.setPhoto(c);
        b2.setPhoto(c);
        b3.setPhoto(c);

        ObjectGraph graph = graphBuilder.getObjectGraph(a, null);
        ObjectGraph graphb2 = graphBuilder.getObjectGraph(b2, null);
        ObjectGraph graphb3 = graphBuilder.getObjectGraph(b3, null);

        pc.getMainCache().addGraphToCache(graph, pc);
        pc.getMainCache().addGraphToCache(graphb2, pc);
        pc.getMainCache().addGraphToCache(graphb3, pc);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT);
        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(3, fs.size());
        flushManager.clearFlushStack();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graphb2.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(2, fs.size());
        flushManager.clearFlushStack();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graphb3.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(2, fs.size());
        flushManager.clearFlushStack();
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @Test
    public void test_1_M_1_M()
    {
        FlushManager flushManager = new FlushManager();
        PhotographerUni_1_M_1_M a = new PhotographerUni_1_M_1_M();
        a.setPhotographerId(1);
        AlbumUni_1_M_1_M b1 = new AlbumUni_1_M_1_M();
        b1.setAlbumId("b1");
        AlbumUni_1_M_1_M b2 = new AlbumUni_1_M_1_M();
        b2.setAlbumId("b2");

        PhotoUni_1_M_1_M c1 = new PhotoUni_1_M_1_M();
        c1.setPhotoId("c1");
        PhotoUni_1_M_1_M c2 = new PhotoUni_1_M_1_M();
        c2.setPhotoId("c2");
        PhotoUni_1_M_1_M c3 = new PhotoUni_1_M_1_M();
        c3.setPhotoId("c3");
        PhotoUni_1_M_1_M c4 = new PhotoUni_1_M_1_M();
        c4.setPhotoId("c4");

        b1.addPhoto(c1);
        b1.addPhoto(c2);
        b2.addPhoto(c3);
        b2.addPhoto(c4);
        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(7, fs.size());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @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());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @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();
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @Test
    public void test_M_M_1_1()
    {
        FlushManager flushManager = new FlushManager();
        PhotographerUni_M_M_1_1 a1 = new PhotographerUni_M_M_1_1();
        a1.setPhotographerId(1);
        PhotographerUni_M_M_1_1 a2 = new PhotographerUni_M_M_1_1();
        a2.setPhotographerId(2);

        AlbumUni_M_M_1_1 b1 = new AlbumUni_M_M_1_1();
        b1.setAlbumId("b1");
        AlbumUni_M_M_1_1 b2 = new AlbumUni_M_M_1_1();
        b2.setAlbumId("b2");
        AlbumUni_M_M_1_1 b3 = new AlbumUni_M_M_1_1();
        b3.setAlbumId("b3");

        PhotoUni_M_M_1_1 c1 = new PhotoUni_M_M_1_1();
        c1.setPhotoId("c1");
        PhotoUni_M_M_1_1 c2 = new PhotoUni_M_M_1_1();
        c2.setPhotoId("c2");
        PhotoUni_M_M_1_1 c3 = new PhotoUni_M_M_1_1();
        c3.setPhotoId("c3");

        b1.setPhoto(c1);
        b2.setPhoto(c2);
        b3.setPhoto(c3);
        a1.addAlbum(b1);
        a1.addAlbum(b2);

        ObjectGraph graph1 = graphBuilder.getObjectGraph(a1, null);

        pc.getMainCache().addGraphToCache(graph1, pc);

        markAllNodeAsDirty();

        flushManager.buildFlushStack(graph1.getHeadNode(), EventType.INSERT);
        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(1, fs.size());
        flushManager.clearFlushStack();

        a2.addAlbum(b2);
        a2.addAlbum(b3);
        ObjectGraph graph2 = graphBuilder.getObjectGraph(a2, null);
        pc.getMainCache().addGraphToCache(graph2, pc);
        markAllNodeAsDirty();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graph2.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(1, fs.size());
    }
View Full Code Here

Examples of com.impetus.kundera.persistence.context.FlushManager

    }

    @Test
    public void test_M_M_M_M()
    {
        FlushManager flushManager = new FlushManager();

        PhotographerUni_M_M_M_M a1 = new PhotographerUni_M_M_M_M();
        a1.setPhotographerId(1);
        PhotographerUni_M_M_M_M a2 = new PhotographerUni_M_M_M_M();
        a2.setPhotographerId(2);

        AlbumUni_M_M_M_M b1 = new AlbumUni_M_M_M_M();
        b1.setAlbumId("b1");
        AlbumUni_M_M_M_M b2 = new AlbumUni_M_M_M_M();
        b2.setAlbumId("b2");
        AlbumUni_M_M_M_M b3 = new AlbumUni_M_M_M_M();
        b3.setAlbumId("b3");

        PhotoUni_M_M_M_M c1 = new PhotoUni_M_M_M_M();
        c1.setPhotoId("c1");
        PhotoUni_M_M_M_M c2 = new PhotoUni_M_M_M_M();
        c2.setPhotoId("c2");
        PhotoUni_M_M_M_M c3 = new PhotoUni_M_M_M_M();
        c3.setPhotoId("c3");
        PhotoUni_M_M_M_M c4 = new PhotoUni_M_M_M_M();
        c4.setPhotoId("c4");

        b1.addPhoto(c1);
        b1.addPhoto(c2);
        b2.addPhoto(c2);
        b2.addPhoto(c3);
        b3.addPhoto(c3);
        b3.addPhoto(c4);
        a1.addAlbum(b1);
        a1.addAlbum(b2);

        ObjectGraph graph1 = graphBuilder.getObjectGraph(a1, null);

        pc.getMainCache().addGraphToCache(graph1, pc);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph1.getHeadNode(), EventType.INSERT);
        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(6, fs.size());
        flushManager.clearFlushStack();

        a2.addAlbum(b2);
        a2.addAlbum(b3);
        ObjectGraph graph2 = graphBuilder.getObjectGraph(a2, null);
        pc.getMainCache().addGraphToCache(graph2, pc);

        markAllNodeAsDirty();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graph2.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(3, fs.size());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.