Examples of PaintingInfo


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

                // testing non-null to-one target
                Painting p0 = results.get(0);
                Object o2 = p0.readPropertyDirectly(Painting.TO_PAINTING_INFO_PROPERTY);
                assertTrue(o2 instanceof PaintingInfo);
                PaintingInfo pi2 = (PaintingInfo) o2;
                assertEquals(PersistenceState.COMMITTED, pi2.getPersistenceState());
                assertEquals(Cayenne.intPKForObject(p0), Cayenne.intPKForObject(pi2));

                // testing null to-one target
                Painting p1 = results.get(1);
                assertNull(p1.readPropertyDirectly(Painting.TO_PAINTING_INFO_PROPERTY));
View Full Code Here

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

    public void testCascadeToOne() {
        // Painting toPaintingInfo
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle("A Title");

        PaintingInfo info = (PaintingInfo) context.newObject("PaintingInfo");
        painting.setToPaintingInfo(info);

        // Must commit before deleting.. this relationship is dependent,
        // and everything must be committed for certain things to work
        context.commitChanges();

        context.deleteObjects(painting);

        // info must also be deleted
        assertEquals(PersistenceState.DELETED, info.getPersistenceState());
        assertNull(info.getPainting());
        assertNull(painting.getToPaintingInfo());
        context.commitChanges();
    }
View Full Code Here

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

        final ObjectContext childContext = runtime.newContext(context);

        final Painting childMaster = childContext.newObject(Painting.class);
        childMaster.setPaintingTitle("Master");

        final PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
        childDetail1.setTextReview("Detail1");
        childDetail1.setPainting(childMaster);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                childContext.commitChangesToParent();

                assertEquals(PersistenceState.COMMITTED, childMaster
                        .getPersistenceState());
                assertEquals(PersistenceState.COMMITTED, childDetail1
                        .getPersistenceState());

                Painting parentMaster = (Painting) context.getGraphManager().getNode(
                        childMaster.getObjectId());

                assertNotNull(parentMaster);
                assertEquals(PersistenceState.NEW, parentMaster.getPersistenceState());

                PaintingInfo parentDetail1 = (PaintingInfo) context
                        .getGraphManager()
                        .getNode(childDetail1.getObjectId());

                assertNotNull(parentDetail1);
                assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());

                assertSame(parentMaster, parentDetail1.getPainting());
                assertSame(parentDetail1, parentMaster.getToPaintingInfo());
            }
        });
    }
View Full Code Here

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

        DataContext context = createDataContext();
        assertSame(getDomain(), context.getParentDataDomain());

        Painting p = context.newObject(Painting.class);
        p.setPaintingTitle("aaaa");
        PaintingInfo pi = context.newObject(PaintingInfo.class);
        pi.setPainting(p);
        context.commitChanges();

        context.invalidateObjects(Arrays.asList(p, pi));

        p.getPaintingTitle();
View Full Code Here

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

        query.addPrefetch(Painting.TO_PAINTING_INFO_PROPERTY);

        List<Painting> objects = context.performQuery(query);
        assertTrue(!objects.isEmpty());
        for (Painting p : objects) {
            PaintingInfo pi = p.getToPaintingInfo();
            assertEquals(PersistenceState.COMMITTED, p.getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, pi.getPersistenceState());
        }
    }
View Full Code Here

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

                // testing non-null to-one target
                Painting p0 = results.get(0);
                Object o2 = p0.readPropertyDirectly(Painting.TO_PAINTING_INFO_PROPERTY);
                assertTrue(o2 instanceof PaintingInfo);
                PaintingInfo pi2 = (PaintingInfo) o2;
                assertEquals(PersistenceState.COMMITTED, pi2.getPersistenceState());
                assertEquals(Cayenne.intPKForObject(p0), Cayenne.intPKForObject(pi2));

                // testing null to-one target
                Painting p1 = results.get(1);
                assertNull(p1.readPropertyDirectly(Painting.TO_PAINTING_INFO_PROPERTY));
View Full Code Here

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

        final ObjectContext childContext = context.createChildContext();

        final Painting childMaster = childContext.newObject(Painting.class);
        childMaster.setPaintingTitle("Master");

        final PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
        childDetail1.setTextReview("Detail1");
        childDetail1.setPainting(childMaster);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                childContext.commitChangesToParent();

                assertEquals(PersistenceState.COMMITTED, childMaster
                        .getPersistenceState());
                assertEquals(PersistenceState.COMMITTED, childDetail1
                        .getPersistenceState());

                Painting parentMaster = (Painting) context.getGraphManager().getNode(
                        childMaster.getObjectId());

                assertNotNull(parentMaster);
                assertEquals(PersistenceState.NEW, parentMaster.getPersistenceState());

                PaintingInfo parentDetail1 = (PaintingInfo) context
                        .getGraphManager()
                        .getNode(childDetail1.getObjectId());

                assertNotNull(parentDetail1);
                assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());

                assertSame(parentMaster, parentDetail1.getPainting());
                assertSame(parentDetail1, parentMaster.getToPaintingInfo());
            }
        });
    }
View Full Code Here

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

    @Inject
    private ObjectContext context1;

    public void testNewAdd1() throws Exception {
        Artist a1 = newArtist();
        PaintingInfo pi1 = newPaintingInfo();
        Painting p1 = newPainting();

        // needed to save without errors
        p1.setToArtist(a1);

        // *** TESTING THIS ***
        pi1.setPainting(p1);

        // test before save
        assertSame(pi1, p1.getToPaintingInfo());
        assertSame(p1, pi1.getPainting());

        // do save
        context.commitChanges();
        context = context1;

        // test database data
        PaintingInfo pi2 = fetchPaintingInfo();
        Painting p2 = pi2.getPainting();
        assertNotNull(p2);
        assertEquals(paintingName, p2.getPaintingTitle());
    }
View Full Code Here

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

    }

    public void testReplace() throws Exception {
        String altPaintingName = "alt painting";

        PaintingInfo pi1 = newPaintingInfo();
        Painting p1 = newPainting();
        p1.setPaintingTitle(altPaintingName);

        pi1.setPainting(p1);

        assertTrue(context.hasChanges());

        // do save
        context.commitChanges();
        context = context1;

        // test database data
        PaintingInfo pi2 = fetchPaintingInfo();
        Painting p21 = pi2.getPainting();
        assertNotNull(p21);
        assertEquals(altPaintingName, p21.getPaintingTitle());
        assertSame(pi2, p21.getToPaintingInfo());
        ByteArrayTypeTest.assertByteArraysEqual(paintingImage, p21
                .getToPaintingInfo()
                .getImageBlob());

        Painting p22 = newPainting();

        // *** TESTING THIS ***
        pi2.setPainting(p22);

        // test before save
        assertNull(p21.getToPaintingInfo());
        assertSame(pi2, p22.getToPaintingInfo());
        assertSame(p22, pi2.getPainting());
        assertEquals(PersistenceState.MODIFIED, pi2.getPersistenceState());

        // do save II
        context.commitChanges();
        ObjectId pi2oid = pi2.getObjectId();
        context = context1;

        PaintingInfo pi3 = fetchPaintingInfo();
        Painting p3 = pi3.getPainting();
        assertNotNull(p3);
        assertEquals(paintingName, p3.getPaintingTitle());
        assertSame(pi3, p3.getToPaintingInfo());

        // test that object id was updated.
        assertEquals(pi2oid, pi3.getObjectId());

    }
View Full Code Here

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

    public void testCascadeToOne() {
        // Painting toPaintingInfo
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle("A Title");

        PaintingInfo info = (PaintingInfo) context.newObject("PaintingInfo");
        painting.setToPaintingInfo(info);

        // Must commit before deleting.. this relationship is dependent,
        // and everything must be committed for certain things to work
        context.commitChanges();

        context.deleteObjects(painting);

        // info must also be deleted
        assertEquals(PersistenceState.DELETED, info.getPersistenceState());
        assertNull(info.getPainting());
        assertNull(painting.getToPaintingInfo());
        context.commitChanges();
    }
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.