### Question:
JapaneseJoyoKanjiValidator extends Validator { @Override public void validate(Sentence sentence) { Set<String> customSkipList = getSet("list"); final Matcher m = nonJoyoKanji.matcher(sentence.getContent()); while (m.find()) { String kanji = m.group(); if (customSkipList == null || !customSkipList.contains(kanji)) { addLocalizedError(sentence, kanji); } } }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence);  }### Answer:
@Test void testValid() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseJoyoKanji")) .build(); List<Document> documents = new ArrayList<>();documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("この文では常用漢字のみを使っています。", 1)) .build()); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(documents).get(documents.get(0)); assertEquals(0, errors.size()); }
@Test void testInvalid() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseJoyoKanji")) .build(); List<Document> documents = new ArrayList<>();documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("惡や學などは常用漢字ではありません。", 1)) .build()); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(documents).get(documents.get(0)); assertEquals(2, errors.size()); assertEquals("JapaneseJoyoKanji", errors.get(0).getValidatorName()); assertEquals("JapaneseJoyoKanji", errors.get(1).getValidatorName()); }
@Test void testSkipWordList() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseJoyoKanji").addProperty("list", "圭,昌")) .build(); List<Document> documents = new ArrayList<>();documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("圭や昌は常用漢字ではありませんが、人名漢字であるため許可します。", 1)) .build()); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(documents).get(documents.get(0)); assertEquals(0, errors.size()); }