if(massiveUpdateTestEnabled) {
List<String> randomWords = Arrays.asList(randomDictionary.split(","));
HashMap<String, String> testerMap = new HashMap<>();
TrieImpl trie = new TrieImpl(mockDb);
Random generator = new Random();
// Random insertion
for (int i = 0; i < 100000; ++i ){
int randomIndex1 = generator.nextInt(randomWords.size());
int randomIndex2 = generator.nextInt(randomWords.size());
String word1 = randomWords.get(randomIndex1).trim();
String word2 = randomWords.get(randomIndex2).trim();
trie.update(word1, word2);
testerMap.put(word1, word2);
}
int half = testerMap.size() / 2;
for (int r = 0; r < half; ++r){
int randomIndex = generator.nextInt(randomWords.size());
String word1 = randomWords.get(randomIndex).trim();
testerMap.remove(word1);
trie.delete(word1);
}
trie.cleanCache();
trie.sync();
// Assert the result now
Iterator<String> keys = testerMap.keySet().iterator();
while (keys.hasNext()){
String mapWord1 = keys.next();
String mapWord2 = testerMap.get(mapWord1);
String treeWord2 = new String(trie.get(mapWord1));
Assert.assertEquals(mapWord2, treeWord2);
}
}
}