### Question:
UnexpandedAcronymValidator extends SpellingDictionaryValidator { @Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } } UnexpandedAcronymValidator(); @Override List<String> getSupportedLanguages(); @Override void validate(Document document); @Override void preValidate(Document document);  }### Answer:
@Test void testDocument() throws RedPenException { List<Document> documents = new ArrayList<>(); documents.add(Document.builder(new WhiteSpaceTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("When it comes to the Subject Of Cake (the sweet and delicious baked delicacy), one should" + " always remember (or at least consider)" + " this foodstuff's effect on one's ever-expanding waistline.", 1)) .addSentence(new Sentence("Now we know what SOC stands for but there is no mention of TTP.", 2)) .addSentence(new Sentence("The acronym CPU stands for Central Processing Unit (CPU).", 3)) .addSentence(new Sentence("The acronym AAAS is the American Association for the Advancement of Science.", 4)) .addSentence(new Sentence("ABC can stand form the Australian Broadcasting Commission, but HELLO is just a capitalized word.", 5)) .build()); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("UnexpandedAcronym")) .build(); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(documents).get(documents.get(0)); assertEquals(1, errors.size()); assertEquals(2, errors.get(0).getLineNumber()); }
@Test void testSimpleSentence() throws Exception { List<Document> documents = new ArrayList<>(); documents.add( Document.builder() .addSection(1) .addParagraph() .addSentence(new Sentence("The JSON data is a output from the command.", 1)) .build()); Configuration config; config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("UnexpandedAcronym")) .build(); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(documents); assertEquals(1, errors.get(documents.get(0)).size()); }
@Test void testLoadSkipList() throws Exception { List<Document> documents = new ArrayList<>();documents.add( Document.builder() .addSection(1) .addParagraph() .addSentence(new Sentence("The output is JSON format.", 1)) .build()); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("UnexpandedAcronym").addProperty("list", "JSON")) .build(); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(documents); assertEquals(0, errors.get(documents.get(0)).size()); }