Package org.apache.art

Examples of org.apache.art.Exhibit


*/
public class CayenneDataObjectValidationTest extends CayenneCase {

    public void testValidateForSaveMandatoryToOneMissing() throws Exception {
        DataContext context = createDataContext();
        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 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


        // first prepare test fixture
        createTestData("testGalleries");
        populateExhibits();

        ObjectId eId = new ObjectId("Exhibit", Exhibit.EXHIBIT_ID_PK_COLUMN, 2);
        Exhibit e = (Exhibit) context.performQuery(new ObjectIdQuery(eId)).get(0);

        assertTrue(e.readPropertyDirectly(Exhibit.TO_GALLERY_PROPERTY) instanceof Fault);

        DataRow snapshot = context.currentSnapshot(e);

        // assert that after taking a snapshot, we have FK in, but the relationship
        // is still a Fault
        assertTrue(e.readPropertyDirectly(Exhibit.TO_GALLERY_PROPERTY) instanceof Fault);
        assertEquals(new Integer(33002), snapshot.get("GALLERY_ID"));
    }
View Full Code Here

        populateExhibits();

        List objects = context.performQuery(new SelectQuery(Exhibit.class));
        assertFalse(objects.isEmpty());

        Exhibit e1 = (Exhibit) objects.get(0);
        assertEquals(java.util.Date.class, e1.getClosingDate().getClass());
    }
View Full Code Here

        assertTrue(g2.readPropertyDirectly("exhibitArray") instanceof ValueHolder);
        List exhibits = (List) g2.readPropertyDirectly("exhibitArray");
        assertFalse(((ValueHolder) exhibits).isFault());
        assertEquals(1, exhibits.size());

        Exhibit e1 = (Exhibit) exhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, e1.getPersistenceState());

        // this to-many must also be resolved
        assertTrue(e1.readPropertyDirectly("artistExhibitArray") instanceof ValueHolder);
        List aexhibits = (List) e1.readPropertyDirectly("artistExhibitArray");
        assertFalse(((ValueHolder) aexhibits).isFault());
        assertEquals(1, exhibits.size());

        ArtistExhibit ae1 = (ArtistExhibit) aexhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, ae1.getPersistenceState());
View Full Code Here

        assertTrue(g2.readPropertyDirectly("exhibitArray") instanceof ValueHolder);
        List exhibits = (List) g2.readPropertyDirectly("exhibitArray");
        assertFalse(((ValueHolder) exhibits).isFault());
        assertEquals(1, exhibits.size());

        Exhibit e1 = (Exhibit) exhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, e1.getPersistenceState());

        // this to-many must also be resolved
        assertTrue(e1.readPropertyDirectly("artistExhibitArray") instanceof ValueHolder);
        List aexhibits = (List) e1.readPropertyDirectly("artistExhibitArray");
        assertFalse(((ValueHolder) aexhibits).isFault());
        assertEquals(2, aexhibits.size());

        ArtistExhibit ae1 = (ArtistExhibit) aexhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, ae1.getPersistenceState());
View Full Code Here

        assertTrue(g2.readPropertyDirectly("exhibitArray") instanceof ValueHolder);
        List exhibits = (List) g2.readPropertyDirectly("exhibitArray");
        assertFalse(((ValueHolder) exhibits).isFault());
        assertEquals(1, exhibits.size());

        Exhibit e1 = (Exhibit) exhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, e1.getPersistenceState());

        // this to-many must also be resolved
        assertTrue(e1.readPropertyDirectly("artistExhibitArray") instanceof ValueHolder);
        List aexhibits = (List) e1.readPropertyDirectly("artistExhibitArray");
        assertFalse(((ValueHolder) aexhibits).isFault());
        assertEquals(2, aexhibits.size());

        ArtistExhibit ae1 = (ArtistExhibit) aexhibits.get(0);
        assertEquals(PersistenceState.COMMITTED, ae1.getPersistenceState());
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

        deleteTestData();
        ctxt = createDataContext();
    }

    protected Exhibit newExhibit(Gallery gallery) {
        Exhibit e1 = (Exhibit) ctxt.newObject("Exhibit");
        e1.setOpeningDate(new Timestamp(System.currentTimeMillis()));
        e1.setClosingDate(new Timestamp(System.currentTimeMillis()));
        e1.setToGallery(gallery);
        return e1;
    }
View Full Code Here

    }

    public void testPropagatePK() throws Exception {
        // setup data
        Gallery g1 = newGallery();
        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());
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 = this.newGallery();
        Exhibit e1 = this.newExhibit(g1);

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

View Full Code Here

TOP

Related Classes of org.apache.art.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.