CustomizeTrie implements ITrie { public boolean buildTrie(String fileName){ try (BufferedReader br = new BufferedReader(new FileReader( fileName))) { String sCurrentLine; while ((sCurrentLine = br.readLine()) != null) { this.add(sCurrentLine.trim()); } } catch (IOException e) { return false; } return true; } CustomizeTrie(); SortedMap<String, List<String>> getDataStructure(); boolean buildTrie(String fileName); void encodeNumber(String fileName); void search(String input, String match,String rawInput);  }
@Test public void testBuildTrie() { boolean buildTrie = customizeTrie.buildTrie("dictionary.txt"); assertTrue(buildTrie); SortedMap<String, List<String>> dataStructure = customizeTrie.getDataStructure(); for (Map.Entry<String, List<String>> entry : dataStructure.entrySet()) { System.out.println(entry.getKey()+" : "+entry.getValue()); } assertArrayEquals(dataStructure.get("10").toArray(new String[]{}), new String[]{"je"}); assertArrayEquals(dataStructure.get("253302").toArray(new String[]{}), new String[]{"Wasser"}); assertArrayEquals(dataStructure.get("4824").toArray(new String[]{}), new String[]{"fort","Torf"}); assertArrayEquals(dataStructure.get("562").toArray(new String[]{}), new String[]{"mir","Mix"}); assertArrayEquals(dataStructure.get("783").toArray(new String[]{}), new String[]{"bo\"s"}); }