public void testFindDuplicates() {
twSearch.store(new JTweet(1L, "wikileaks is not a wtf", new JUser("userA")), false);
twSearch.store(new JTweet(2L, "news about wikileaks", new JUser("userB")), false);
// find dup is restricted to the last hour so use a current date
MyDate dt = new MyDate();
JTweet tw3 = new JTweet(3L, "wtf means wikileaks task force", new JUser("userC")).setCreatedAt(dt.toDate());
JTweet tw4 = new JTweet(4L, "wtf wikileaks task force", new JUser("userD")).setCreatedAt(dt.plusMinutes(1).toDate());
JTweet tw5 = new JTweet(5L, "RT @userC: wtf means wikileaks task force", new JUser("userE")).setCreatedAt(dt.plusMinutes(1).toDate());
twSearch.queueObjects(Arrays.asList(tw3, tw4, tw5));
twSearch.forceEmptyQueueAndRefresh();
assertEquals("should be empty. should NOT find tweet 4 because it is younger", 0, tw3.getDuplicates().size());
assertEquals("should find tweet 3", 1, tw4.getDuplicates().size());
Map<Long, JTweet> map = new LinkedHashMap<Long, JTweet>();
JTweet tw = new JTweet(10L, "wtf wikileaks task force", new JUser("peter")).setCreatedAt(dt.plusMinutes(1).toDate());
map.put(10L, tw);
twSearch.findDuplicates(map);
assertEquals("should find tweets 3 and 4", 2, tw.getDuplicates().size());
}