DateTime now = DateTime.now();
Date d2 = now.toDateMidnight().toDate();
Date d1 = now.minusDays(1).toDateMidnight().toDate();
//create a file move for a user 1
FileMove mv1 = new FileMove(key1(), "foo", "bar", false);
mv1.when = d2;
//create a file move for a user 2 that's too old to be included
FileMove mv2 = new FileMove(key2(), "foo", "bar", false);
mv2.when = now.minusDays(3).toDate();
FileMove.save(Arrays.asList(mv1, mv2));
int count = UserStatsUtil.countUniqueFileMoveUsers("when", d1, FileMove.all());
assertEquals(1, count);
//create a file move for user 2
FileMove mv3 = new FileMove(key2(), "rick", "james", false);
FileMove.save(Arrays.asList(mv3));
int newCount = UserStatsUtil.countUniqueFileMoveUsers("when", d1, FileMove.all());
assertEquals(2, newCount);
}