Package org.apache.cayenne.testdo.testmap

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


    }

    public void testUnregisterThenRegister() throws Exception {

        // Create a gallery.
        Gallery g = context.newObject(Gallery.class);
        g.setGalleryName("Test Gallery");

        // Create an artist in the same context.
        Artist a = context.newObject(Artist.class);
        a.setArtistName("Test Artist");
View Full Code Here


        dbHelper.deleteAll("ARTIST");
        dbHelper.deleteAll("EXHIBIT");
        dbHelper.deleteAll("GALLERY");

        // prepare a single gallery record
        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("version1");

        // prepare a single artist record
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName("version1");
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

        BeanValidationFailure failure = (BeanValidationFailure) failures.get(0);
        assertEquals(Exhibit.TO_GALLERY_PROPERTY, failure.getProperty());

        // fix the problem and see if it goes away
        Gallery gallery = context.newObject(Gallery.class);
        exhibit.setToGallery(gallery);
        result = new ValidationResult();
        exhibit.validateForSave(result);
        assertFalse("No failures expected: " + result, result.hasFailures());
    }
View Full Code Here

        List<?> objects = context.performQuery(query);

        assertNotNull(objects);
        assertEquals(1, objects.size());
        Gallery gallery = (Gallery) objects.get(0);
        assertEquals("gallery2", gallery.getGalleryName());

    }
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.deleteObjects(gallery);
            fail("Should have thrown an exception");
View Full Code Here

    }

    public void testExtras() throws Exception {
        ObjectId oid1 = new ObjectId("Gallery", "GALLERY_ID", 1);
        ObjectId oid2 = new ObjectId("Gallery", "GALLERY_ID", 2);
        Gallery g1 = new Gallery();
        Gallery g2 = new Gallery();
        g1.setObjectId(oid1);
        g2.setObjectId(oid2);

        Expression e1 = ExpressionFactory.matchExp("toGallery", g1);
        Expression e2 = e1.orExp(ExpressionFactory.matchExp("toGallery", g2));

        TstExpressionCase extraCase = new TstExpressionCase(
View Full Code Here

    public void testReadToOneRel3() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        Gallery g1 = p1.getToGallery();
        assertNull(g1);
    }
View Full Code Here

                    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

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.