IUserPersistence users = dbs.getDatabase1().users();
long t0 = System.currentTimeMillis();
long t1 = t0 + 10;
long t2 = t0 + 20;
byte[] someBinary = new byte[]{5, 4, 3, 2, 1};
User bryand = users.create("bryand", t0, 5, t1, t2, "this is a relatively long string", someBinary, 1.2d, 3.4d, true);
User notBryand = users.create("notBryand", t0, 3, t1, t2, "another relatively long string", someBinary, 1.2d, 3.4d, true);
users.create("unwanted", t0, 0, t1, t2, "yet another relatively long string", someBinary, 1.2d, 3.4d, true);
users.clearCacheById(bryand.getId());
users.clearCacheById(notBryand.getId());
Set<Long> keysToSearch = new HashSet<Long>();
keysToSearch.add(bryand.getId());
keysToSearch.add(notBryand.getId());
Set<User> foundValues = users.find(keysToSearch);
assertEquals(2, foundValues.size());
Iterator<User> iter = foundValues.iterator();
User bryand_again = null;
User notBryand_again = null;
while (iter.hasNext()) {
User curUser = iter.next();
if (curUser.getId() == bryand.getId()) {
bryand_again = curUser;
} else if (curUser.getId() == notBryand.getId()) {
notBryand_again = curUser;
} else {
fail("Unexpected user id: " + curUser.getId());
}
}
assertNotNull(bryand_again);
assertNotNull(notBryand_again);