• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ljacqu / wordeval / 14890732001

07 May 2025 06:33PM UTC coverage: 60.614% (-0.8%) from 61.437%
14890732001

push

github

ljacqu
Fix line processor tests not to depend on the dictionary files

392 of 702 branches covered (55.84%)

0 of 2 new or added lines in 1 file covered. (0.0%)

26 existing lines in 5 files now uncovered.

968 of 1597 relevant lines covered (60.61%)

3.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.09
/src/main/java/ch/jalu/wordeval/dictionary/DictionaryService.java
1
package ch.jalu.wordeval.dictionary;
2

3
import ch.jalu.wordeval.DataUtils;
4
import ch.jalu.wordeval.dictionary.hunspell.HunspellDictionaryService;
5
import ch.jalu.wordeval.dictionary.hunspell.lineprocessor.HunspellLineProcessor;
6
import org.apache.commons.lang3.StringUtils;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.stereotype.Service;
9

10
import java.util.ArrayList;
11
import java.util.List;
12
import java.util.stream.Stream;
13

14
/**
15
 * Service for processing dictionaries.
16
 */
17
@Service
18
public class DictionaryService {
19

20
  @Autowired
21
  private DataUtils dataUtils;
22

23
  @Autowired
24
  private HunspellDictionaryService hunspellDictionaryService;
25

26
  DictionaryService() {
2✔
27
  }
1✔
28

29
  /**
30
   * Reads all words from the dictionary's file and sanitizes them.
31
   *
32
   * @param dictionary the dictionary to load
33
   * @return all words of the dictionary
34
   */
35
  public List<Word> readAllWords(Dictionary dictionary) {
UNCOV
36
    WordFactory wordFactory = new WordFactory(dictionary.getLanguage());
×
UNCOV
37
    try (Stream<String> lines = dataUtils.lines(dictionary.getFile())) {
×
UNCOV
38
      return loadWords(lines, dictionary)
×
UNCOV
39
          .filter(StringUtils::isNotEmpty)
×
UNCOV
40
          .map(wordFactory::createWordObject)
×
UNCOV
41
          .toList();
×
42
    }
43
  }
44

45
  private Stream<String> loadWords(Stream<String> lines, Dictionary dictionary) {
UNCOV
46
    return switch (dictionary) {
×
UNCOV
47
      case HunspellDictionary hunDict -> hunspellDictionaryService.loadAllWords(lines, hunDict);
×
48
    };
49
  }
50

51
  public DictionaryLines processWordsForDebug(Dictionary dictionary) {
52
    if (dictionary instanceof HunspellDictionary hunDict) {
×
53
      HunspellLineProcessor lineProcessor = hunDict.getLineProcessor();
×
54
      List<String> skippedLines = new ArrayList<>();
×
55
      List<String> includedLines = new ArrayList<>();
×
56

57
      dataUtils.readAllLines(dictionary.getFile()).forEach(line -> {
×
UNCOV
58
        if (lineProcessor.split(line).isEmpty()) {
×
59
          skippedLines.add(line);
×
60
        } else {
61
          includedLines.add(line);
×
62
        }
UNCOV
63
      });
×
64
      return new DictionaryLines(skippedLines, includedLines);
×
65
    }
66

UNCOV
67
    throw new IllegalStateException("Unsupported dictionary type: " + dictionary.getClass());
×
68
  }
69

UNCOV
70
  public record DictionaryLines(List<String> skippedLines, List<String> includedLines) {
×
71
  }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc