Package org.apache.cayenne.testdo.testmap

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


        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                512), null);
        assertEquals("No Painting Like This", p.getPaintingTitle());
    }
View Full Code Here


        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                300), null);
        assertEquals("Go Figure", p.getPaintingTitle());
    }
View Full Code Here

    }

    public void testInvalidateRootWithChangedToOneTarget() 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());

        context.invalidateObjects(Collections.singletonList(painting));
        assertNotSame(artistBefore, painting.getToArtist());
        assertEquals("artist3", painting.getToArtist().getArtistName());
    }
View Full Code Here

    }

    public void testInvalidateRootWithNullToOneTargetChangedToNotNull() 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());

        context.invalidateObjects(Collections.singletonList(painting));
        assertNotNull(painting.getToArtist());
        assertEquals("artist2", painting.getToArtist().getArtistName());
    }
View Full Code Here

    public void testModifyHollow() throws Exception {

        createSingleArtistAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);
        final Artist artist = painting.getToArtist();
        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
        assertNull(artist.readPropertyDirectly("artistName"));

        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
View Full Code Here

        ToManyList list = createForNewArtist();
        assertFalse("Expected resolved list when created with a new object", list
                .isFault());
        assertEquals(0, list.size());

        Painting p1 = context.newObject(Painting.class);
        list.add(p1);
        assertEquals(1, list.size());

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertEquals(2, list.size());

        list.remove(p1);
        assertEquals(1, list.size());
View Full Code Here

        // bypassing normal CayenneDataObject methods
        list.getRelationshipOwner().setPersistenceState(PersistenceState.MODIFIED);

        assertTrue("List must be unresolved for an existing object", list.isFault());

        Painting p1 = context.newObject(Painting.class);
        list.add(p1);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p1));

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p2));

        list.remove(p1);
View Full Code Here

    }

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

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

        // 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);
        context.commitChanges();

        // immediately tag Artist as MODIFIED, since we are messing up with relationship
        // bypassing normal CayenneDataObject methods
        list.getRelationshipOwner().setPersistenceState(PersistenceState.MODIFIED);

        assertTrue("List must be unresolved...", list.isFault());
        list.add(p1);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p1));

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p2));

        // now resolve the list and see how merge worked
View Full Code Here

    }

    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

    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

TOP

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

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.