Package org.mongodb.morphia.TestQuery

Examples of org.mongodb.morphia.TestQuery.ContainsPic


        assertInserted(res);
        assertEquals(1, getDs().find(ContainsPic.class).countAll());

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

    }
View Full Code Here


    }

    @Test
    public void testUpdateRef() throws Exception {
        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

TOP

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

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.