Package org.apache.cayenne.testdo.testmap

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


        createSingleArtistDataSet();

        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
                Artist.ARTIST_NAME_PROPERTY,
                "artist1"));
        Artist artist = (Artist) context.performQuery(query).get(0);

        DataRow snapshot = context.currentSnapshot(artist);
        assertEquals(artist.getArtistName(), snapshot.get("ARTIST_NAME"));
        assertEquals(artist.getDateOfBirth(), snapshot.get("DATE_OF_BIRTH"));
    }
View Full Code Here


        // test null values
        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
                Artist.ARTIST_NAME_PROPERTY,
                "artist1"));
        Artist artist = (Artist) context.performQuery(query).get(0);

        artist.setArtistName(null);
        artist.setDateOfBirth(null);

        DataRow snapshot = context.currentSnapshot(artist);
        assertTrue(snapshot.containsKey("ARTIST_NAME"));
        assertNull(snapshot.get("ARTIST_NAME"));
View Full Code Here

        // test null values
        SelectQuery query = new SelectQuery(Artist.class, ExpressionFactory.matchExp(
                Artist.ARTIST_NAME_PROPERTY,
                "artist1"));
        Artist artist = (Artist) context.performQuery(query).get(0);

        // test FK relationship snapshotting
        Painting p1 = new Painting();
        context.registerNewObject(p1);
        p1.setToArtist(artist);

        DataRow s1 = context.currentSnapshot(p1);
        Map<String, Object> idMap = artist.getObjectId().getIdSnapshot();
        assertEquals(idMap.get("ARTIST_ID"), s1.get("ARTIST_ID"));
    }
View Full Code Here

     */
    public void testCharFetch() throws Exception {
        createSingleArtistDataSet();

        SelectQuery query = new SelectQuery(Artist.class);
        Artist a = (Artist) context.performQuery(query).get(0);
        assertEquals(a.getArtistName().trim(), a.getArtistName());
    }
View Full Code Here

        query.setDistinct(true);

        List<Artist> objects = context.performQuery(query);
        assertEquals(5, objects.size());

        Artist artist = objects.get(0);
        DataRow snapshot = context.getObjectStore().getSnapshot(artist.getObjectId());
        assertEquals(3, snapshot.size());

        // assert the ordering
        assertEquals("artist1", objects.get(0).getArtistName());
        assertEquals("arTist2", objects.get(1).getArtistName());
View Full Code Here

        try {
            while (it.hasNextRow()) {
                DataRow row = (DataRow) it.nextRow();

                // try instantiating an object and fetching its relationships
                Artist artist = context.objectFromDataRow(Artist.class, row);
                List<?> paintings = artist.getPaintingArray();
                assertNotNull(paintings);
                assertEquals("Expected one painting for artist: " + artist, 1, paintings
                        .size());
            }
        }
View Full Code Here

     * property is simply set to the same value (an unreal modification)
     */
    public void testHasChangesPhantom() {

        String artistName = "ArtistName";
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName(artistName);
        context.commitChanges();

        // Set again to *exactly* the same value
        artist.setArtistName(artistName);

        // note that since 1.2 the polciy is for hasChanges to return true for phantom
        // modifications, as there is no way to detect some more subtle modifications like
        // a change of the master related object, until we actually create the PKs
        assertTrue(context.hasChanges());
View Full Code Here

    /**
     * Tests that hasChanges performs correctly when an object is "modified" and the
     * property is simply set to the same value (an unreal modification)
     */
    public void testHasChangesRealModify() {
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName("ArtistName");
        context.commitChanges();

        artist.setArtistName("Something different");
        assertTrue(context.hasChanges());
    }
View Full Code Here

    public void testBeforeHollowDeleteShouldChangeStateToCommited() throws Exception {
        createSingleArtistDataSet();

        ObjectId gid = new ObjectId("Artist", "ARTIST_ID", 33001);
        final Artist inflated = new Artist();
        inflated.setPersistenceState(PersistenceState.COMMITTED);
        inflated.setObjectId(gid);
        inflated.setArtistName("artist1");

        Artist hollow = (Artist) context.localObject(gid, null);
        assertEquals(PersistenceState.HOLLOW, hollow.getPersistenceState());

        // testing this...
        context.deleteObject(hollow);
        assertSame(hollow, context.getGraphManager().getNode(gid));
        assertEquals(inflated.getArtistName(), hollow.getArtistName());

        assertEquals(PersistenceState.DELETED, hollow.getPersistenceState());
    }
View Full Code Here

    public void testRefreshNullifiedValuesNew() {

        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        a.setArtistName("X");
        a.setDateOfBirth(new Date());

        context.commitChanges();

        context.performGenericQuery(new SQLTemplate(
                Artist.class,
                "UPDATE ARTIST SET DATE_OF_BIRTH = NULL"));

        long id = Cayenne.longPKForObject(a);
        ObjectIdQuery query = new ObjectIdQuery(new ObjectId(
                "Artist",
                Artist.ARTIST_ID_PK_COLUMN,
                id), false, ObjectIdQuery.CACHE_REFRESH);

        Artist a1 = (Artist) Cayenne.objectForQuery(context, query);
        assertNull(a1.getDateOfBirth());
        assertEquals("X", a1.getArtistName());
    }
View Full Code Here

TOP

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

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.