Esempio n. 1
0
  protected void init() {

    builder = new TrieBuilder();

    builder.buildTrie(TRIE_SIZE);

    trie = builder.getTrie();
  }
Esempio n. 2
0
  public void testTrieStructure() {

    List<String> nextCharacterList = new LinkedList<String>();
    nextCharacterList.addAll(trie.getNextNodeCharacterSet());

    Collections.sort(nextCharacterList);

    for (String c : nextCharacterList) {

      List<Method> wordList = trie.getWordList(c);

      List<Method> indexedList = builder.getListForFirstCharacter(c);

      Collections.sort(wordList, methodComparator);
      Collections.sort(indexedList, methodComparator);

      for (int i = 0; i < wordList.size(); i++) {

        Method found = wordList.get(i);
        Method indexed = wordList.get(i);

        String foundString = found.toString();
        String indexedString = indexed.toString();

        if (!foundString.equals(indexedString)) {
          System.out.println("found = " + found.toString());
          System.out.println("as indexed = " + indexed.toString());
        }

        assertEquals(found.toString(), indexed.toString());
      }

      for (int i = wordList.size(); i < indexedList.size(); i++) {

        System.out.println("found = NONE");
        System.out.println("as indexed = " + indexedList.get(i).toString());
      }

      // get the list of elements that are not in the union of the two lists
      @SuppressWarnings("unchecked")
      Collection<Method> disjunctionList = CollectionUtils.disjunction(wordList, indexedList);

      for (Method method : disjunctionList) {

        System.out.println("missing = " + method.toString());
      }

      assertEquals(wordList.size(), indexedList.size());
    }
  }