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());
}