Package org.apache.cayenne.testdo.testmap

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


                        .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
                assertEquals(2, toMany.size());

                ArtistExhibit artistExhibit = (ArtistExhibit) toMany.get(0);
                assertEquals(PersistenceState.COMMITTED, artistExhibit
                        .getPersistenceState());
                assertSame(a1, artistExhibit.getToArtist());

                Artist a2 = artists.get(1);
                assertEquals("artist3", a2.getArtistName());
                List<?> toMany2 = (List<?>) a2
                        .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
                assertNotNull(toMany2);
                assertFalse(((ValueHolder) toMany2).isFault());
                assertEquals(3, toMany2.size());

                ArtistExhibit artistExhibit2 = (ArtistExhibit) toMany2.get(0);
                assertEquals(PersistenceState.COMMITTED, artistExhibit2
                        .getPersistenceState());
                assertSame(a2, artistExhibit2.getToArtist());
            }
        });
    }
View Full Code Here


                List<?> toMany = (List<?>) a1.readPropertyDirectly("artistExhibitArray");
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
                assertEquals(2, toMany.size());

                ArtistExhibit artistExhibit = (ArtistExhibit) toMany.get(0);
                assertEquals(PersistenceState.COMMITTED, artistExhibit
                        .getPersistenceState());
                assertSame(a1, artistExhibit.getToArtist());

                Artist a2 = artists.get(1);
                assertEquals("artist3", a2.getArtistName());
                List<?> toMany2 = (List<?>) a2
                        .readPropertyDirectly(Artist.ARTIST_EXHIBIT_ARRAY_PROPERTY);
                assertNotNull(toMany2);
                assertFalse(((ValueHolder) toMany2).isFault());
                assertEquals(3, toMany2.size());

                ArtistExhibit artistExhibit2 = (ArtistExhibit) toMany2.get(0);
                assertEquals(PersistenceState.COMMITTED, artistExhibit2
                        .getPersistenceState());
                assertSame(a2, artistExhibit2.getToArtist());
            }
        });
    }
View Full Code Here

    public void testNewAdd2() throws Exception {
        Artist a1 = this.newArtist();
        Gallery g1 = this.newGallery();
        Exhibit e1 = this.newExhibit(g1);

        ArtistExhibit ae1 = this.newArtistExhibit();
        ae1.setToArtist(a1);
        ae1.setToExhibit(e1);

        // do save

        // *** TESTING THIS ***
        ctxt.commitChanges();
View Full Code Here

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

                Iterator<ArtistExhibit> exibitsIterator = exibits.iterator();
                while (exibitsIterator.hasNext()) {
                    ArtistExhibit ae = exibitsIterator.next();
                    assertEquals(PersistenceState.COMMITTED, ae.getPersistenceState());
                    assertNotNull(ae.getObjectId());

                }
            }
        });
    }
View Full Code Here

        Exhibit e1 = newExhibit(g1);
        Artist a1 = newArtist();
        ctxt.commitChanges();

        // *** TESTING THIS ***
        ArtistExhibit ae1 = (ArtistExhibit) ctxt.newObject("ArtistExhibit");
        e1.addToArtistExhibitArray(ae1);
        a1.addToArtistExhibitArray(ae1);

        // check before save
        assertSame(e1, ae1.getToExhibit());
        assertSame(a1, ae1.getToArtist());

        // save
        // test "assertion" is that commit succeeds (PK of ae1 was set properly)
        ctxt.commitChanges();
    }
View Full Code Here

        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");

        anExhibit.setToGallery(gallery);

        ArtistExhibit artistExhibit = (ArtistExhibit) context.newObject("ArtistExhibit");

        artistExhibit.setToArtist(anArtist);
        artistExhibit.setToExhibit(anExhibit);
        context.commitChanges();

        context.deleteObject(anArtist);

        // Test that the link record was deleted, and removed from the relationship
        assertEquals(PersistenceState.DELETED, artistExhibit.getPersistenceState());
        assertFalse(anArtist.getArtistExhibitArray().contains(artistExhibit));
        context.commitChanges();
    }
View Full Code Here

   
    public void testReadNestedPropertyToManyInMiddle() throws Exception {
        DataContext context = createDataContext();
       
        Artist a = context.newObject(Artist.class);
        ArtistExhibit ex = context.newObject(ArtistExhibit.class);
        Painting p1 = context.newObject(Painting.class);
        Painting p2 = context.newObject(Painting.class);
        p1.setPaintingTitle("p1");
        p2.setPaintingTitle("p2");
        a.addToPaintingArray(p1);
        a.addToPaintingArray(p2);
        ex.setToArtist(a);
       
        List<String> names = (List<String>) a.readNestedProperty("paintingArray.paintingTitle");
        assertEquals(names.size(), 2);
        assertEquals(names.get(0), "p1");
        assertEquals(names.get(1), "p2");
       
        List<String> names2 = (List<String>)
            ex.readNestedProperty("toArtist.paintingArray.paintingTitle");
        assertEquals(names, names2);
    }
View Full Code Here

   
    public void testReadNestedPropertyToManyInMiddle1() throws Exception {
        DataContext context = createDataContext();
       
        Artist a = context.newObject(Artist.class);
        ArtistExhibit ex = context.newObject(ArtistExhibit.class);
        Painting p1 = context.newObject(Painting.class);
        Painting p2 = context.newObject(Painting.class);
        p1.setPaintingTitle("p1");
        p2.setPaintingTitle("p2");
        a.addToPaintingArray(p1);
        a.addToPaintingArray(p2);
        ex.setToArtist(a);
       
        List<String> names = (List<String>) a.readNestedProperty("paintingArray+.paintingTitle");
        assertEquals(names.size(), 2);
        assertEquals(names.get(0), "p1");
        assertEquals(names.get(1), "p2");
       
        List<String> names2 = (List<String>)
            ex.readNestedProperty("toArtist.paintingArray+.paintingTitle");
        assertEquals(names, names2);
    }
View Full Code Here

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

        ArtistExhibit ae1 = context.newObject(ArtistExhibit.class);
        ae1.setToArtist(a1);
        ae1.setToExhibit(e1);

        // *** TESTING THIS ***
        context.commitChanges();
    }
View Full Code Here

        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");

        anExhibit.setToGallery(gallery);

        ArtistExhibit artistExhibit = (ArtistExhibit) context.newObject("ArtistExhibit");

        artistExhibit.setToArtist(anArtist);
        artistExhibit.setToExhibit(anExhibit);
        context.commitChanges();

        context.deleteObjects(anArtist);

        // Test that the link record was deleted, and removed from the relationship
        assertEquals(PersistenceState.DELETED, artistExhibit.getPersistenceState());
        assertFalse(anArtist.getArtistExhibitArray().contains(artistExhibit));
        context.commitChanges();
    }
View Full Code Here

TOP

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

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.