/** * @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); }
@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); }
@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()); }
@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); }
/** * 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; }