Package org.apache.cayenne.testdo.testmap

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


    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);

        ArtistExhibit ae1 = context.newObject(ArtistExhibit.class);
        ae1.setToArtist(a1);
        ae1.setToExhibit(e1);
View Full Code Here


    @Inject
    private ObjectContext context;

    public void testValidateForSaveMandatoryToOneMissing() throws Exception {

        Exhibit exhibit = context.newObject(Exhibit.class);
        exhibit.setOpeningDate(new Date());
        exhibit.setClosingDate(new Date());

        ValidationResult result = new ValidationResult();
        exhibit.validateForSave(result);

        assertTrue("Validation of 'toGallery' should've failed.", result.hasFailures());
        assertTrue(result.hasFailures(exhibit));

        List<ValidationFailure> failures = result.getFailures();
        assertEquals(1, failures.size());

        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

    public void testCascadeToMany() {
        // Artist artistExhibitArray
        Artist anArtist = (Artist) context.newObject("Artist");
        anArtist.setArtistName("A Name");
        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");

        artistExhibit.setToArtist(anArtist);
        artistExhibit.setToExhibit(anExhibit);
View Full Code Here

        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());

        context.commitChanges();

        // *** TESTING THIS ***
        ArtistExhibit ae1 = context.newObject(ArtistExhibit.class);
        e1.addToArtistExhibitArray(ae1);
        a1.addToArtistExhibitArray(ae1);

        // check before save
        assertSame(e1, ae1.getToExhibit());
        assertSame(a1, ae1.getToArtist());
View Full Code Here

TOP

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

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.