Package org.mongodb.morphia.TestQuery

Examples of org.mongodb.morphia.TestQuery.Pic


        assertEquals(13D, cLoaded.getRadius(), 0D);
    }

    @Test
    public void testInsertWithRef() throws Exception {
        final Pic pic = new Pic();
        pic.setName("fist");
        final Key<Pic> picKey = getDs().save(pic);

        //test with Key<Pic>
        UpdateResults res = getDs().updateFirst(getDs().find(ContainsPic.class, "name", "first").filter("pic", picKey),
                                                getDs().createUpdateOperations(ContainsPic.class).set("name", "A"), true);
View Full Code Here


        final ContainsPic cp = new ContainsPic();
        cp.setName("cp one");

        getDs().save(cp);

        final Pic pic = new Pic();
        pic.setName("fist");
        final Key<Pic> picKey = getDs().save(pic);


        //test with Key<Pic>
        final UpdateResults res = getDs().updateFirst(getDs().find(ContainsPic.class, "name", cp.getName()),
                                                      getDs().createUpdateOperations(ContainsPic.class).set("pic", pic));

        assertEquals(1, res.getUpdatedCount());

        //test reading the object.
        final ContainsPic cp2 = getDs().find(ContainsPic.class).get();
        assertNotNull(cp2);
        assertEquals(cp2.getName(), cp.getName());
        assertNotNull(cp2.getPic());
        assertNotNull(cp2.getPic().getName());
        assertEquals(cp2.getPic().getName(), pic.getName());

        getDs().updateFirst(getDs().find(ContainsPic.class, "name", cp.getName()),
                            getDs().createUpdateOperations(ContainsPic.class).set("pic", picKey));

        //test reading the object.
        final ContainsPic cp3 = getDs().find(ContainsPic.class).get();
        assertNotNull(cp3);
        assertEquals(cp3.getName(), cp.getName());
        assertNotNull(cp3.getPic());
        assertNotNull(cp3.getPic().getName());
        assertEquals(cp3.getPic().getName(), pic.getName());
    }
View Full Code Here

        final ContainsPicKey cpk = new ContainsPicKey();
        cpk.name = "cpk one";

        getDs().save(cpk);

        final Pic pic = new Pic();
        pic.setName("fist again");
        final Key<Pic> picKey = getDs().save(pic);
        // picKey = getDs().getKey(pic);


        //test with Key<Pic>
View Full Code Here

TOP

Related Classes of org.mongodb.morphia.TestQuery.Pic

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.