### Question:
DefaultWordCounter implements WordCounter { @Override public int countWords (Note note) { int count = 0; String[] fields = {note.getTitle(), note.getContent()}; for (String field : fields) { field = sanitizeTextForWordsAndCharsCount(note, field); boolean word = false; int endOfLine = field.length() - 1; for (int i = 0; i < field.length(); i++) { if (Character.isLetter(field.charAt(i)) && i != endOfLine) { word = true; } else if (!Character.isLetter(field.charAt(i)) && word) { count++; word = false; } else if (Character.isLetter(field.charAt(i)) && i == endOfLine) { count++; } } } return count; }  @Override int countWords(Note note); @Override int countChars(Note note);  }### Answer:
@Test public void getWords () { Note note = getNote(1L, "one two", "three\n four five"); assertEquals(5, new DefaultWordCounter().countWords(note)); note.setTitle("singleword"); assertEquals(4, new DefaultWordCounter().countWords(note)); }
@Test public void getChecklistWords () { String content = CHECKED_SYM + "done\n" + UNCHECKED_SYM + "undone yet"; Note note = getNote(1L, "checklist", content); note.setChecklist(true); assertEquals(4, new DefaultWordCounter().countWords(note)); }