@@ -0,0 +1,2842 @@
+/* LanguageTool, a natural language style checker %0A * Copyright (C) 2018 Daniel Naber (http://www.danielnaber.de)%0A * %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301%0A * USA%0A */%0Apackage org.languagetool.rules.es;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.languagetool.JLanguageTool;%0Aimport org.languagetool.TestTools;%0Aimport org.languagetool.language.Spanish;%0Aimport org.languagetool.rules.RuleMatch;%0A%0Aimport java.io.IOException;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A *%0A * @author (adapted from Portuguese version by David M%C3%A9ndez)%0A * @since 4.1%0A */%0Apublic class SpanishWikipediaRuleTest %7B%0A%0A  private SpanishWikipediaRule rule;%0A  private JLanguageTool langTool;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    rule = new SpanishWikipediaRule(TestTools.getMessages(%22es%22));%0A    langTool = new JLanguageTool(new Spanish());%0A  %7D%0A%0A  @Test%0A  public void testRule() throws IOException %7B%0A%0A    // correct sentences:%0A    assertEquals(0, rule.match(langTool.getAnalyzedSentence(%22Estas frases no tienen errores frecuentes en la Wikipedia.%22)).length);%0A%0A    // incorrect sentences:%0A%0A    // at the beginning of a sentence (replace rule is case-sensitive)%0A    checkSimpleReplaceRule(%22Sucedi%C3%B3 ayer. Murio sin que nadie lo esperase.%22, %22Muri%C3%B3%22);%0A    // inside sentence%0A    checkSimpleReplaceRule(%22Ayer murio sin que nadie lo esperase.%22, %22muri%C3%B3%22);%0A  %7D%0A%0A  /**%0A   * Check if a specific replace rule applies.%0A   * @param sentence the sentence containing the incorrect/misspelled word.%0A   * @param word the word that is correct (the suggested replacement).%0A   */%0A  private void checkSimpleReplaceRule(String sentence, String word) throws IOException %7B%0A    RuleMatch%5B%5D matches = rule.match(langTool.getAnalyzedSentence(sentence));%0A    assertEquals(%22Invalid matches.length while checking sentence: %22%0A            + sentence, 1, matches.length);%0A    assertEquals(%22Invalid replacement count wile checking sentence: %22%0A            + sentence, 1, matches%5B0%5D.getSuggestedReplacements().size());%0A    assertEquals(%22Invalid suggested replacement while checking sentence: %22%0A            + sentence, word, matches%5B0%5D.getSuggestedReplacements().get(0));%0A  %7D%0A%7D%0A

Add a test for SpanishWikipediaRule