Package com.github.jmkgreen.morphia.TestQuery

Examples of com.github.jmkgreen.morphia.TestQuery.ContainsPic


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

    //test reading the object.
    ContainsPic cp = ds.find(ContainsPic.class).get();
    assertNotNull(cp);
    assertEquals(cp.name, "second");
    assertNotNull(cp.pic);
    assertNotNull(cp.pic.name);
    assertEquals(cp.pic.name, "fist");
View Full Code Here


   
  }
 
  @Test
    public void testUpdateRef() throws Exception {
    ContainsPic cp = new ContainsPic();
    cp.name = "cp one";

    Key<ContainsPic> cpKey = ds.save(cp);
   
    Pic pic = new Pic();
    pic.name = "fist";
    Key<Pic> picKey = ds.save(pic);


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

    assertEquals(1, res.getUpdatedCount());

    //test reading the object.
    ContainsPic cp2 = ds.find(ContainsPic.class).get();
    assertNotNull(cp2);
    assertEquals(cp2.name, cp.name);
    assertNotNull(cp2.pic);
    assertNotNull(cp2.pic.name);
    assertEquals(cp2.pic.name, pic.name);
   
    res = ds.updateFirst(
        ds.find(ContainsPic.class, "name", cp.name),
        ds.createUpdateOperations(ContainsPic.class).set("pic", picKey));
   
    //test reading the object.
    ContainsPic cp3 = ds.find(ContainsPic.class).get();
    assertNotNull(cp3);
    assertEquals(cp3.name, cp.name);
    assertNotNull(cp3.pic);
    assertNotNull(cp3.pic.name);
    assertEquals(cp3.pic.name, pic.name);
View Full Code Here

TOP

Related Classes of com.github.jmkgreen.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.