@Test public void testWordCount() { InnerClassWordsCounter wordsCounter = new InnerClassWordsCounter(); List book = new ArrayList<>(); Map<String, Integer> testCount = new TreeMap<>(); Map<String, Integer> count; String one = "a a a"; String two = "b b"; book.add(one); book.add(two); testCount.put("a", 3); testCount.put("b", 2); count = wordsCounter.wordCount(book); assertThat(testCount, is(count)); }
@Test public void testCombineSeparateCounts() { InnerClassWordsCounter wordsCounter = new InnerClassWordsCounter(); List<Map<String, Integer>> raw = new ArrayList<>(); Map<String, Integer> testCount1 = new TreeMap<>(); testCount1.put("a", 3); testCount1.put("b", 1); Map<String, Integer> testCount2 = new TreeMap<>(); testCount2.put("a", 3); testCount2.put("b", 1); raw.add(testCount1); raw.add(testCount2); Map<String, Integer> testCountCombined = new TreeMap<>(); testCountCombined.put("a", 6); testCountCombined.put("b", 2); Map<String, Integer> countCombined = new TreeMap<>(); countCombined = wordsCounter.combineSeparateCounts(raw); assertThat(testCountCombined, is(countCombined)); }