@Test public void testExtractReturnsOneOccurrence() { String message = "Poker poker poker poker poker poker"; Map<String, Long> result = testObj.extract(message, Lists.newArrayList("Poker","Tournament")); assertNotNull(result); assertThat(result, Matchers.allOf(hasEntry(is("Poker"), is(1L)))); }
public Map<String, Long> extract(String text, List<String> keywords) { Map<String, Long> result = Maps.newHashMap(); keywords.forEach(new Consumer<String>() { @Override public void accept(String keyword) { if (text.contains(keyword)) { result.put(keyword, 1L); } } }); return result; }
KeywordStatistics { public Map<String, Long> extract(String text, List<String> keywords) { Map<String, Long> result = Maps.newHashMap(); keywords.forEach(new Consumer<String>() { @Override public void accept(String keyword) { if (text.contains(keyword)) { result.put(keyword, 1L); } } }); return result; } }
KeywordStatistics { public Map<String, Long> extract(String text, List<String> keywords) { Map<String, Long> result = Maps.newHashMap(); keywords.forEach(new Consumer<String>() { @Override public void accept(String keyword) { if (text.contains(keyword)) { result.put(keyword, 1L); } } }); return result; }  }
KeywordStatistics { public Map<String, Long> extract(String text, List<String> keywords) { Map<String, Long> result = Maps.newHashMap(); keywords.forEach(new Consumer<String>() { @Override public void accept(String keyword) { if (text.contains(keyword)) { result.put(keyword, 1L); } } }); return result; }  Map<String, Long> extract(String text, List<String> keywords); }
KeywordStatistics { public Map<String, Long> extract(String text, List<String> keywords) { Map<String, Long> result = Maps.newHashMap(); keywords.forEach(new Consumer<String>() { @Override public void accept(String keyword) { if (text.contains(keyword)) { result.put(keyword, 1L); } } }); return result; }  Map<String, Long> extract(String text, List<String> keywords);  }