assertEquals(user.getAge(), savedUser.getAge());
}
@Test
public void saveWithArray() {
Item item0 = new Item();
item0.setName("Foo0");
JOhm.save(item0);
Item item1 = new Item();
item1.setName("Foo1");
JOhm.save(item1);
Item item2 = new Item();
item2.setName("Foo2");
JOhm.save(item2);
User user = new User();
user.setName("foo");
user.setRoom("vroom");
user.setThreeLatestPurchases(new Item[] { item0, item1, item2 });
user = JOhm.save(user);
assertNotNull(user);
User savedUser = JOhm.get(User.class, user.getId());
assertEquals(user.getName(), savedUser.getName());
assertNull(savedUser.getRoom());
assertEquals(user.getId(), savedUser.getId());
assertEquals(user.getAge(), savedUser.getAge());
Item[] saved = savedUser.getThreeLatestPurchases();
assertEquals(3, saved.length);
assertEquals(item0.getId(), saved[0].getId());
assertEquals(item0.getName(), saved[0].getName());
assertEquals(item1.getId(), saved[1].getId());
assertEquals(item1.getName(), saved[1].getName());
assertEquals(item2.getId(), saved[2].getId());
assertEquals(item2.getName(), saved[2].getName());
assertTrue(JOhm.delete(User.class, savedUser.getId(), true, true));
assertTrue(JOhm.delete(Item.class, item0.getId()));
assertTrue(JOhm.delete(Item.class, item1.getId()));
assertTrue(JOhm.delete(Item.class, item2.getId()));
}