Examples of Painting


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

    }

    public void testThrowOutDeleted() throws Exception {
        ToManyList list = createForExistingArtist();

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

        // list being tested is a separate copy from
        // the relationship list that Artist has, so adding a painting
        // here will not add the painting to the array being tested
        ((Artist) list.getRelationshipOwner()).addToPaintingArray(p1);
View Full Code Here

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

    public void testRealRelationship() throws Exception {
        Artist artist = context.newObject(Artist.class);
        artist.setArtistName("aaa");

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

        context.commitChanges();
        context.invalidateObjects(Collections.singletonList(artist));

        ToManyList list = (ToManyList) artist.getPaintingArray();
        assertTrue("List must be unresolved...", list.isFault());

        Painting p2 = context.newObject(Painting.class);
        p2.setPaintingTitle("p2");

        artist.addToPaintingArray(p1);
        artist.addToPaintingArray(p2);
        assertTrue("List must be unresolved...", list.isFault());
View Full Code Here

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

    public void testRealRelationshipRollback() throws Exception {
        Artist artist = context.newObject(Artist.class);
        artist.setArtistName("aaa");

        Painting p1 = context.newObject(Painting.class);
        p1.setPaintingTitle("p1");
        artist.addToPaintingArray(p1);
        context.commitChanges();
        context.invalidateObjects(Collections.singletonList(artist));

        ToManyList list = (ToManyList) artist.getPaintingArray();
        assertTrue("List must be unresolved...", list.isFault());

        Painting p2 = context.newObject(Painting.class);

        artist.addToPaintingArray(p2);
        assertTrue("List must be unresolved...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p2));
View Full Code Here

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

        diff.apply(diffChecker);
        assertEquals(1, diffChecker.getCallbackCount());
        assertSame(a.getObjectId(), newIds[0]);
       
        // commit a mix of new and modified
        Painting p = context.newObject(Painting.class);
        p.setPaintingTitle("PT");
        p.setToArtist(a);
        a.setArtistName(a.getArtistName() + "_");
       
        GraphDiff diff2 = context.flushToParent(true);
        assertNotNull(diff2);
        assertFalse(context.hasChanges());

        final Object[] newIds2 = new Object[1];

        MockGraphChangeHandler diffChecker2 = new MockGraphChangeHandler() {

            @Override
            public void nodeIdChanged(Object nodeId, Object newId) {
                super.nodeIdChanged(nodeId, newId);

                newIds2[0] = newId;
            }
        };

        diff2.apply(diffChecker2);
        assertEquals(1, diffChecker2.getCallbackCount());
        assertSame(p.getObjectId(), newIds2[0]);
    }
View Full Code Here

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

    }

    public void testRefetchRootWithNullifiedToOne() throws Exception {
        createSingleArtistAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);

        assertNotNull(painting.getToArtist());
        assertEquals("artist2", painting.getToArtist().getArtistName());

        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());

        // select without prefetch
        painting = (Painting) context
                .performQuery(new SelectQuery(Painting.class))
                .get(0);
        assertNotNull(painting);
        assertNull(painting.getToArtist());
    }
View Full Code Here

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

    }

    public void testRefetchRootWithChangedToOneTarget() throws Exception {
        createTwoArtistsAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);

        Artist artistBefore = painting.getToArtist();
        assertNotNull(artistBefore);
        assertEquals("artist2", artistBefore.getArtistName());

        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());

        // select without prefetch
        painting = (Painting) context
                .performQuery(new SelectQuery(Painting.class))
                .get(0);
        assertNotNull(painting);
        assertEquals("artist3", painting.getToArtist().getArtistName());
    }
View Full Code Here

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

    }

    public void testRefetchRootWithNullToOneTargetChangedToNotNull() throws Exception {
        createSingleArtistAndUnrelatedPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);

        assertNull(painting.getToArtist());

        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());

        // select without prefetch
        painting = (Painting) context
                .performQuery(new SelectQuery(Painting.class))
                .get(0);
        assertNotNull(painting);
        assertEquals("artist2", painting.getToArtist().getArtistName());
    }
View Full Code Here

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

    public void testInvalidateRootWithNullifiedToOne() throws Exception {

        createSingleArtistAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);

        assertNotNull(painting.getToArtist());
        assertEquals("artist2", painting.getToArtist().getArtistName());

        assertEquals(1, tPainting.update().set("ARTIST_ID", null, Types.BIGINT).execute());

        context.invalidateObjects(Collections.singletonList(painting));
        assertNull(painting.getToArtist());
    }
View Full Code Here

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

                        .readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
                assertEquals(1, toMany.size());

                Painting p1 = (Painting) toMany.get(0);
                assertEquals("p_" + a1.getArtistName(), p1.getPaintingTitle());

                Artist a2 = artists.get(1);
                List<?> toMany2 = (List<?>) a2
                        .readPropertyDirectly(Artist.PAINTING_ARRAY_PROPERTY);
                assertNotNull(toMany2);
                assertFalse(((ValueHolder) toMany2).isFault());
                assertEquals(1, toMany2.size());

                Painting p2 = (Painting) toMany2.get(0);
                assertEquals("p_" + a2.getArtistName(), p2.getPaintingTitle());
            }
        });
    }
View Full Code Here

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

                    List<?> toMany = (List<?>) a.readPropertyDirectly("paintingArray");
                    assertNotNull(toMany);
                    assertFalse(((ValueHolder) toMany).isFault());
                    assertEquals(1, toMany.size());

                    Painting p = (Painting) toMany.get(0);
                    assertEquals("Invalid prefetched painting:" + p, "p_"
                            + a.getArtistName(), p.getPaintingTitle());
                }
            }
        });
    }
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.