Package org.apache.cayenne.testdo.testmap

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


        Expression notBetween = new ASTNotBetween(
                new ASTObjPath("estimatedPrice"),
                new BigDecimal(10d),
                new BigDecimal(20d));

        Painting noMatch = new Painting();
        noMatch.setEstimatedPrice(new BigDecimal(21));
        assertFalse(between.match(noMatch));
        assertTrue(notBetween.match(noMatch));

        Painting match1 = new Painting();
        match1.setEstimatedPrice(new BigDecimal(20));
        assertTrue(between.match(match1));
        assertFalse(notBetween.match(match1));

        Painting match2 = new Painting();
        match2.setEstimatedPrice(new BigDecimal(10));
        assertTrue("Failed: " + between, between.match(match2));
        assertFalse("Failed: " + notBetween, notBetween.match(match2));

        Painting match3 = new Painting();
        match3.setEstimatedPrice(new BigDecimal(11));
        assertTrue("Failed: " + between, between.match(match3));
        assertFalse("Failed: " + notBetween, notBetween.match(match3));
    }
View Full Code Here


        Expression notIn = new ASTNotIn(new ASTObjPath("estimatedPrice"), new ASTList(
                new Object[] {
                        new BigDecimal("10"), new BigDecimal("20")
                }));

        Painting noMatch1 = new Painting();
        noMatch1.setEstimatedPrice(new BigDecimal("21"));
        assertFalse(in.match(noMatch1));
        assertTrue(notIn.match(noMatch1));

        Painting noMatch2 = new Painting();
        noMatch2.setEstimatedPrice(new BigDecimal("11"));
        assertFalse("Failed: " + in, in.match(noMatch2));
        assertTrue("Failed: " + notIn, notIn.match(noMatch2));

        Painting match1 = new Painting();
        match1.setEstimatedPrice(new BigDecimal("20"));
        assertTrue(in.match(match1));
        assertFalse(notIn.match(match1));

        Painting match2 = new Painting();
        match2.setEstimatedPrice(new BigDecimal("10"));
        assertTrue("Failed: " + in, in.match(match2));
        assertFalse("Failed: " + notIn, notIn.match(match2));
    }
View Full Code Here

    }

    public void testReadNestedProperty1() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        assertEquals("aX", p1.readNestedProperty("toArtist.artistName"));
    }
View Full Code Here

    }

    public void testReadNestedProperty2() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        assertTrue(p1.getToArtist().readNestedProperty("paintingArray") instanceof List<?>);
    }
View Full Code Here

    }

    public void testReciprocalRel1() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        Artist a1 = p1.getToArtist();

        assertNotNull(a1);
        assertEquals("aX", a1.getArtistName());

        List<Painting> paintings = a1.getPaintingArray();
        assertEquals(1, paintings.size());
        Painting p2 = paintings.get(0);
        assertSame(p1, p2);
    }
View Full Code Here

    }

    public void testReadToOneRel1() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        Artist a1 = p1.getToArtist();

        assertNotNull(a1);
        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
        assertEquals("aX", a1.getArtistName());
        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
View Full Code Here

    public void testReadToOneRel2() throws Exception {
        // test chained calls to read relationships
        createArtistWithPaintingAndInfoDataSet();

        PaintingInfo pi1 = Cayenne.objectForPK(context, PaintingInfo.class, 6);
        Painting p1 = pi1.getPainting();
        p1.getPaintingTitle();

        Artist a1 = p1.getToArtist();

        assertNotNull(a1);
        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
        assertEquals("aX", a1.getArtistName());
        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
View Full Code Here

    }

    public void testReadToOneRel3() throws Exception {
        createArtistWithPaintingDataSet();

        Painting p1 = Cayenne.objectForPK(context, Painting.class, 6);
        Gallery g1 = p1.getToGallery();
        assertNull(g1);
    }
View Full Code Here

        // Create this object in one context...
        Artist artist = context.newObject(Artist.class);

        // ...and this object in another context
        Painting painting = runtime.getContext().newObject(Painting.class);

        // Check setting a toOne relationship
        try {
            painting.setToArtist(artist);
            fail("Should have failed to set a cross-context relationship");
        }
        catch (CayenneRuntimeException e) {
            // Fine.. it should throw an exception
        }

        assertNull(painting.getToArtist()); // Make sure it wasn't set

        // Now try the reverse (toMany) relationship
        try {
            artist.addToPaintingArray(painting);
            fail("Should have failed to add a cross-context relationship");
View Full Code Here

        artist.setArtistName("a name");

        context.commitChanges();

        // Cause an update and an insert that need correct ordering
        Painting painting = context.newObject(Painting.class);
        painting.setPaintingTitle("a painting");
        artist.addToPaintingArray(painting);

        context.commitChanges();

        context.deleteObject(artist);
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.