Package org.apache.cayenne.testdo.testmap

Examples of org.apache.cayenne.testdo.testmap.Gallery


                    assertTrue(expectedPaintingsNames.contains(p.getPaintingTitle()));
                }
                String artistName = (String) firstRow[1];
                assertEquals("A1", artistName);

                Gallery g1 = (Gallery) firstRow[2];
                assertEquals("gallery1", g1.getGalleryName());

                List<Exhibit> exibits = g1.getExhibitArray();

                assertNotNull(exibits);
                assertFalse(((ValueHolder) exibits).isFault());
                assertEquals(2, exibits.size());

                Object[] secondRow = (Object[]) objects.get(1);
                a = (Artist) secondRow[0];
                assertEquals("A2", a.getArtistName());

                paintings = a.getPaintingArray();

                assertNotNull(paintings);
                assertFalse(((ValueHolder) paintings).isFault());
                assertEquals(1, paintings.size());

                expectedPaintingsNames = new ArrayList<String>();
                expectedPaintingsNames.add("P2");

                paintingsIterator = paintings.iterator();
                while (paintingsIterator.hasNext()) {
                    Painting p = paintingsIterator.next();
                    assertEquals(PersistenceState.COMMITTED, p.getPersistenceState());
                    assertNotNull(p.getPaintingTitle());
                    assertTrue(expectedPaintingsNames.contains(p.getPaintingTitle()));
                }
                artistName = (String) secondRow[1];
                assertEquals("A2", artistName);

                Gallery g2 = (Gallery) secondRow[2];
                assertEquals(g1, g2);
            }
        });
    }
View Full Code Here


                    assertTrue(expectedPaintingsNames.contains(p.getPaintingTitle()));
                }
                String artistName1 = (String) row[1];
                assertEquals("A1", artistName1);

                Gallery g1 = (Gallery) row[2];
                assertEquals("gallery1", g1.getGalleryName());

                List<?> exibits = g1.getExhibitArray();

                assertNotNull(exibits);
                assertFalse(((ValueHolder) exibits).isFault());
                assertEquals(2, exibits.size());

                row = (Object[]) objects.get(1);

                assertEquals(a1, row[0]);
                assertEquals(artistName1, row[1]);

                Gallery g2 = (Gallery) row[2];
                assertEquals("gallery2", g2.getGalleryName());

                exibits = g2.getExhibitArray();

                assertTrue(exibits.isEmpty());

                row = (Object[]) objects.get(2);
View Full Code Here

        assertEquals(2, a2.getPaintingArray().size());
    }

    public void testRemove1() throws Exception {
        Painting p1 = newPainting();
        Gallery g1 = newGallery();
        g1.addToPaintingArray(p1);

        // do save
        ctxt.commitChanges();
        ctxt = createDataContext();

        // test database data
        Gallery g2 = fetchGallery();
        Painting p2 = (Painting) g2.getPaintingArray().get(0);

        // *** TESTING THIS ***
        g2.removeFromPaintingArray(p2);

        // test before save
        assertEquals(0, g2.getPaintingArray().size());
        assertNull(p2.getToGallery());

        // do save II
        ctxt.commitChanges();
        ctxt = createDataContext();

        Painting p3 = fetchPainting();
        assertNull(p3.getToGallery());

        Gallery g3 = fetchGallery();
        assertEquals(0, g3.getPaintingArray().size());
    }
View Full Code Here

        Gallery g3 = fetchGallery();
        assertEquals(0, g3.getPaintingArray().size());
    }

    public void testRemove2() throws Exception {
        Gallery g1 = newGallery();
        g1.addToPaintingArray(newPainting());
        g1.addToPaintingArray(newPainting());

        // do save
        ctxt.commitChanges();
        ctxt = createDataContext();

        // test database data
        Gallery g2 = fetchGallery();
        assertEquals(2, g2.getPaintingArray().size());
        Painting p2 = (Painting) g2.getPaintingArray().get(0);

        // *** TESTING THIS ***
        g2.removeFromPaintingArray(p2);

        // test before save
        assertEquals(1, g2.getPaintingArray().size());
        assertNull(p2.getToGallery());

        // do save II
        ctxt.commitChanges();
        ctxt = createDataContext();

        Gallery g3 = fetchGallery();
        assertEquals(1, g3.getPaintingArray().size());
    }
View Full Code Here

        assertEquals(1, g3.getPaintingArray().size());
    }

    public void testPropagatePK() throws Exception {
        // setup data
        Gallery g1 = newGallery();
        Exhibit e1 = newExhibit(g1);
        Artist a1 = newArtist();
        ctxt.commitChanges();

        // *** TESTING THIS ***
 
View Full Code Here

        Exhibit anExhibit = (Exhibit) context.newObject("Exhibit");
        anExhibit.setClosingDate(new java.sql.Timestamp(System.currentTimeMillis()));
        anExhibit.setOpeningDate(new java.sql.Timestamp(System.currentTimeMillis()));

        // Needs a gallery... required for data integrity
        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");

        anExhibit.setToGallery(gallery);

        ArtistExhibit artistExhibit = (ArtistExhibit) context.newObject("ArtistExhibit");
View Full Code Here

        context.commitChanges();
    }

    public void testDenyToMany() {
        // Gallery paintingArray
        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle("A Title");
        gallery.addToPaintingArray(painting);
        context.commitChanges();

        try {
            context.deleteObject(gallery);
            fail("Should have thrown an exception");
View Full Code Here

    protected ArtistExhibit newArtistExhibit() {
        return (ArtistExhibit) ctxt.newObject("ArtistExhibit");
    }

    protected Gallery newGallery() {
        Gallery g1 = (Gallery) ctxt.newObject("Gallery");
        g1.setGalleryName(galleryName);
        return g1;
    }
View Full Code Here

    }

    /** Tests how primary key is propagated from one new object to another. */
    public void testNewAdd2() throws Exception {
        Artist a1 = this.newArtist();
        Gallery g1 = context.newObject(Gallery.class);
        g1.setGalleryName(galleryName);

        Exhibit e1 = context.newObject(Exhibit.class);
        e1.setOpeningDate(new Timestamp(System.currentTimeMillis()));
        e1.setClosingDate(new Timestamp(System.currentTimeMillis()));
        e1.setToGallery(g1);
View Full Code Here

    public void testPropagatePK() throws Exception {
        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("XyBn");

        Gallery g1 = context.newObject(Gallery.class);
        g1.setGalleryName("Tyu");

        Exhibit e1 = context.newObject(Exhibit.class);
        e1.setToGallery(g1);
        e1.setOpeningDate(new Date());
        e1.setClosingDate(new Date());
View Full Code Here

TOP

Related Classes of org.apache.cayenne.testdo.testmap.Gallery

Copyright © 2018 www.massapicom. 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.