Examples of Gallery


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

    public void testReplace() throws Exception {

        Painting p1 = context.newObject(Painting.class);
        p1.setPaintingTitle("xa");

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

        p1.setToGallery(g1);

        context.commitChanges();
        ObjectContext context2 = runtime.getContext();

        // test database data
        Painting p2 = (Painting) Cayenne.objectForQuery(context2, new SelectQuery(
                Painting.class));
        Gallery g21 = p2.getToGallery();
        assertNotNull(g21);
        assertEquals("yTW", g21.getGalleryName());
        assertEquals(1, g21.getPaintingArray().size());
        assertSame(p2, g21.getPaintingArray().get(0));

        Gallery g22 = context2.newObject(Gallery.class);
        g22.setGalleryName("rE");
        p2.setToGallery(g22);

        // test before save
        assertEquals(0, g21.getPaintingArray().size());
        assertEquals(1, g22.getPaintingArray().size());
        assertSame(p2, g22.getPaintingArray().get(0));

        // do save II
        context2.commitChanges();

        ObjectContext context3 = runtime.getContext();

        Painting p3 = (Painting) Cayenne.objectForQuery(context3, new SelectQuery(
                Painting.class));
        Gallery g3 = p3.getToGallery();
        assertNotNull(g3);
        assertEquals("rE", g3.getGalleryName());
        assertEquals(1, g3.getPaintingArray().size());
        assertSame(p3, g3.getPaintingArray().get(0));
    }
View Full Code Here

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

        // test database data
        Painting p2 = (Painting) Cayenne.objectForQuery(context2, new SelectQuery(
                Painting.class));
        assertNull(p2.getToGallery());

        Gallery g2 = context2.newObject(Gallery.class);
        g2.setGalleryName("rE");

        p2.setToGallery(g2);

        // test before save
        assertEquals(1, g2.getPaintingArray().size());
        assertSame(p2, g2.getPaintingArray().get(0));

        // do save II
        context2.commitChanges();
        ObjectContext context3 = runtime.getContext();

        Painting p3 = (Painting) Cayenne.objectForQuery(context3, new SelectQuery(
                Painting.class));
        Gallery g3 = p3.getToGallery();
        assertNotNull(g3);
        assertEquals("rE", g3.getGalleryName());
        assertEquals(1, g3.getPaintingArray().size());
        assertSame(p3, g3.getPaintingArray().get(0));
    }
View Full Code Here

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

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

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

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

    }

    /** 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

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

        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

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

    }

    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

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

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

                    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

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

        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

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

        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
TOP
Copyright © 2018 www.massapi.com. 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.