/**
  * @param stack
  * @param key
  * @param obj
  */
 private void attachPListObjToDictParent(PListObject obj, java.lang.String key) {
   if (Log.isLoggable(TAG, Log.VERBOSE)) {
     Log.v(
         stringer.newBuilder().append(TAG).append("#attachPListObjToDictParent").toString(),
         stringer
             .newBuilder()
             .append("key|obj-type|obj: ")
             .append(key)
             .append(Constants.PIPE)
             .append(obj.getType())
             .append(Constants.PIPE)
             .append(obj.toString())
             .append(Constants.PIPE)
             .toString());
   }
   Dict parent = (Dict) stack.pop();
   parent.putConfig(key, obj);
   stack.push(parent);
 }
Exemple #2
0
  @Test(groups = "unit-tests", enabled = false)
  public void getWords() throws Exception {
    Set<IWord> words =
        fixture
            .entrySet()
            .stream()
            .map(
                pair ->
                    new Word(
                        pair.getKey(),
                        new HashSet<String>(pair.getValue()),
                        (long) pair.getValue().size()))
            .collect(Collectors.toSet());

    IDict dict = Dict.create(words);
    assertEquals(dict.getWords(), words);
  }
Exemple #3
0
  @Test(groups = "unit-tests", enabled = false)
  public void testSearchNoResults() throws Exception {
    Set<IWord> words =
        fixture
            .entrySet()
            .stream()
            .map(
                pair ->
                    new Word(
                        pair.getKey(),
                        new HashSet<String>(pair.getValue()),
                        (long) pair.getValue().size()))
            .collect(Collectors.toSet());

    ISearchable dict = Dict.create(words);
    Optional actual = dict.search("bingo");
    assertFalse(actual.isPresent());
  }
Exemple #4
0
  @Test(groups = "unit-tests", enabled = false)
  public void testSearch() throws Exception {
    IWord expectedIWord = new Word("see", fixture.remove("see"), 0l);
    Set<IWord> words =
        fixture
            .entrySet()
            .stream()
            .map(
                pair ->
                    new Word(
                        pair.getKey(),
                        new HashSet<String>(pair.getValue()),
                        (long) pair.getValue().size()))
            .collect(Collectors.toSet());
    words.add(expectedIWord);

    ISearchable dict = Dict.create(words);
    Optional actual = dict.search("foreseen");
    assertEquals(actual.get(), expectedIWord);
  }
Exemple #5
0
 /**
  * Sets the hangman word's length.
  *
  * @param wordLength The word length
  */
 private void setLength(int wordLength) {
   if (!dict.hasLength(wordLength))
     throw new IllegalArgumentException("Game dict has no words of " + "length " + length);
   length = wordLength;
 }