/** */
@Test
public void testBatchOperations() throws Exception {
fact().register(Trivial.class);
Trivial triv1 = new Trivial("foo", 5);
Trivial triv2 = new Trivial("foo2", 6);
List<Trivial> objs = new ArrayList<>();
objs.add(triv1);
objs.add(triv2);
Map<Key<Trivial>, Trivial> map = ofy().save().entities(objs).now();
List<Key<Trivial>> keys = new ArrayList<>(map.keySet());
// Verify the put keys
assert keys.size() == objs.size();
for (int i=0; i<objs.size(); i++)
{
assert keys.get(i).getId() == objs.get(i).getId();
}
// Now fetch and verify the data
Map<Key<Trivial>, Trivial> fetched = ofy().load().keys(keys);
assert fetched.size() == keys.size();
for (Trivial triv: objs)
{
Trivial fetchedTriv = fetched.get(Key.create(triv));
assert triv.getSomeNumber() == fetchedTriv.getSomeNumber();
assert triv.getSomeString().equals(fetchedTriv.getSomeString());
}
}