posts.save(post);
assertEquals(post, posts.find(50));
}
public void testFindWithFieldsMap() throws IOException, SQLException {
IUserPersistence users = dbs.getDatabase1().users();
User u1 = users.create("a_handle", 2);
users.save(u1);
User u2 = users.create("another_handle", 2);
Set<User> found = users.find(new HashMap<Enum, Object>() {
{
put(User._Fields.handle, "a_handle");
put(User._Fields.some_float, null);
}
});
assertEquals(1, found.size());
assertTrue(found.contains(u1));
found = users.find(new HashMap<Enum, Object>() {
{
put(User._Fields.num_posts, 2);
}
});
assertEquals(2, found.size());
assertTrue(found.contains(u1));
assertTrue(found.contains(u2));
found = users.query().id(u1.getId()).numPosts(2).find();
assertEquals(1, found.size());
assertTrue(found.contains(u1));
}