Package org.apache.art

Examples of org.apache.art.Artist


        SelectQuery query = new SelectQuery(Artist.class);

        // select both, a2 should go second...
        List artists = c1.performQuery(query);
        Artist a1 = (Artist) artists.get(0);

        List altArtists = c2.performQuery(query);
        final Artist a2 = (Artist) altArtists.get(0);
        assertNotNull(a2);
        assertFalse(a2 == a1);

        // Update Artist
        a1.setArtistName(NEW_NAME);
View Full Code Here


    public void testSelectSelectCommitRefreshReverse() throws Exception {

        SelectQuery query = new SelectQuery(Artist.class);

        List altArtists = c2.performQuery(query);
        final Artist a2 = (Artist) altArtists.get(0);

        List artists = c1.performQuery(query);
        Artist a1 = (Artist) artists.get(0);

        assertFalse(a2 == a1);

        // Update Artist
        a1.setArtistName(NEW_NAME);
        c1.commitChanges();

        assertOnCommit(a2);
    }
View Full Code Here

    public void testSelectUpdateSelectCommitRefresh() throws Exception {

        SelectQuery query = new SelectQuery(Artist.class);

        List artists = c1.performQuery(query);
        Artist a1 = (Artist) artists.get(0);

        // Update Artist
        a1.setArtistName(NEW_NAME);

        List altArtists = c2.performQuery(query);
        final Artist a2 = (Artist) altArtists.get(0);
        assertNotNull(a2);
        assertFalse(a2 == a1);

        c1.commitChanges();
        assertOnCommit(a2);
View Full Code Here

public class NestedDataContextParentPeerEventsTest extends CayenneCase {

    public void testPeerObjectUpdatedSimpleProperty() throws Exception {
        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        a.setArtistName("X");
        context.commitChanges();

        DataContext parentPeer = context.getParentDataDomain().createDataContext();
        Artist a1 = (Artist) parentPeer.localObject(a.getObjectId(), a);

        final ObjectContext peer2 = context.createChildContext();
        final Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        a1.setArtistName("Y");
        assertEquals("X", a2.getArtistName());
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals("Y", a2.getArtistName());

                assertFalse("Peer data context became dirty on event processing", peer2
                        .hasChanges());
            }
        }.assertWithTimeout(2000);
View Full Code Here

    public void testPeerObjectUpdatedToOneRelationship() throws Exception {

        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        Artist altA = context.newObject(Artist.class);

        Painting p = context.newObject(Painting.class);
        p.setToArtist(a);
        p.setPaintingTitle("PPP");
        a.setArtistName("X");
        altA.setArtistName("Y");
        context.commitChanges();

        DataContext parentPeer = context.getParentDataDomain().createDataContext();
        Painting p1 = (Painting) parentPeer.localObject(p.getObjectId(), p);
        Artist altA1 = (Artist) parentPeer.localObject(altA.getObjectId(), altA);

        final ObjectContext peer2 = context.createChildContext();
        final Painting p2 = (Painting) peer2.localObject(p.getObjectId(), p);
        final Artist altA2 = (Artist) peer2.localObject(altA.getObjectId(), altA);
        Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        p1.setToArtist(altA1);
        assertSame(a2, p2.getToArtist());
        assertNotSame(altA2, p2.getToArtist());
        parentPeer.commitChangesToParent();
View Full Code Here

    public void testPeerObjectUpdatedToManyRelationship() throws Exception {

        DataContext context = createDataContext();

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

        Painting px = context.newObject(Painting.class);
        px.setToArtist(a);
        px.setPaintingTitle("PX");

        Painting py = context.newObject(Painting.class);
        py.setPaintingTitle("PY");

        context.commitChanges();

        DataContext parentPeer = context.getParentDataDomain().createDataContext();
        Painting py1 = (Painting) parentPeer.localObject(py.getObjectId(), py);
        Artist a1 = (Artist) parentPeer.localObject(a.getObjectId(), a);

        final ObjectContext peer2 = context.createChildContext();
        final Painting py2 = (Painting) peer2.localObject(py.getObjectId(), py);
        final Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        a1.addToPaintingArray(py1);
        assertEquals(1, a2.getPaintingArray().size());
        assertFalse(a2.getPaintingArray().contains(py2));
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(2, a2.getPaintingArray().size());
                assertTrue(a2.getPaintingArray().contains(py2));

                assertFalse("Peer data context became dirty on event processing", peer2
                        .hasChanges());
            }
        }.assertWithTimeout(2000);
View Full Code Here

    public void testPeerObjectUpdatedTempOID() {
        DataContext context = createDataContext();

        ObjectContext peer1 = context.createChildContext();
        Artist a1 = peer1.newObject(Artist.class);
        a1.setArtistName("Y");
        ObjectId a1TempId = a1.getObjectId();

        ObjectContext peer2 = context.createChildContext();
        Artist a2 = (Artist) peer2.localObject(a1TempId, a1);

        assertEquals(a1TempId, a2.getObjectId());

        peer1.commitChanges();
        assertFalse(a1.getObjectId().isTemporary());
        assertFalse(a2.getObjectId().isTemporary());
        assertEquals(a2.getObjectId(), a1.getObjectId());
    }
View Full Code Here

    }

    public void testPeerObjectUpdatedSimpleProperty() {
        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        a.setArtistName("X");
        context.commitChanges();

        ObjectContext peer1 = context.createChildContext();
        Artist a1 = (Artist) peer1.localObject(a.getObjectId(), a);

        ObjectContext peer2 = context.createChildContext();
        Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        a1.setArtistName("Y");
        assertEquals("X", a2.getArtistName());
        peer1.commitChangesToParent();
        assertEquals("Y", a2.getArtistName());

        assertFalse("Peer data context became dirty on event processing", peer2
                .hasChanges());
    }
View Full Code Here

    public void testPeerObjectUpdatedToOneRelationship() {

        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        Artist altA = context.newObject(Artist.class);

        Painting p = context.newObject(Painting.class);
        p.setToArtist(a);
        p.setPaintingTitle("PPP");
        a.setArtistName("X");
        altA.setArtistName("Y");
        context.commitChanges();

        ObjectContext peer1 = context.createChildContext();
        Painting p1 = (Painting) peer1.localObject(p.getObjectId(), p);
        Artist altA1 = (Artist) peer1.localObject(altA.getObjectId(), altA);

        ObjectContext peer2 = context.createChildContext();
        Painting p2 = (Painting) peer2.localObject(p.getObjectId(), p);
        Artist altA2 = (Artist) peer2.localObject(altA.getObjectId(), altA);
        Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        p1.setToArtist(altA1);
        assertSame(a2, p2.getToArtist());
        peer1.commitChangesToParent();
        assertEquals(altA2, p2.getToArtist());
View Full Code Here

    public void testPeerObjectUpdatedToManyRelationship() {

        DataContext context = createDataContext();

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

        Painting px = context.newObject(Painting.class);
        px.setToArtist(a);
        px.setPaintingTitle("PX");

        Painting py = context.newObject(Painting.class);
        py.setPaintingTitle("PY");

        context.commitChanges();

        ObjectContext peer1 = context.createChildContext();
        Painting py1 = (Painting) peer1.localObject(py.getObjectId(), py);
        Artist a1 = (Artist) peer1.localObject(a.getObjectId(), a);

        ObjectContext peer2 = context.createChildContext();
        Painting py2 = (Painting) peer2.localObject(py.getObjectId(), py);
        Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        a1.addToPaintingArray(py1);
        assertEquals(1, a2.getPaintingArray().size());
        assertFalse(a2.getPaintingArray().contains(py2));
        peer1.commitChangesToParent();
        assertEquals(2, a2.getPaintingArray().size());
        assertTrue(a2.getPaintingArray().contains(py2));

        assertFalse("Peer data context became dirty on event processing", peer2
                .hasChanges());
    }
View Full Code Here

TOP

Related Classes of org.apache.art.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.