package org.languagetool.rules.el;

/* LanguageTool, a natural language style checker
 * Copyright (C) 2019 Daniel Naber (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

import org.junit.Test;
import org.languagetool.JLanguageTool;
import org.languagetool.Languages;
import org.languagetool.TestTools;
import org.languagetool.rules.RuleMatch;

import java.io.IOException;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
/**
 * SpecificCaseRule TestCase
 */
public class SpecificCaseRuleTest {

	private final JLanguageTool lt = new JLanguageTool(Languages.getLanguageForShortCode("el"));
	private final SpecificCaseRule rule = new SpecificCaseRule(TestTools.getEnglishMessages());

	@Test
	public void testRule() throws IOException {
		assertGood("Ηνωμένες Πολιτείες");
		assertGood("Κατοικώ στις Ηνωμένες Πολιτείες.");
		assertGood("Κατοικώ στις ΗΝΩΜΕΝΕΣ ΠΟΛΙΤΕΙΕΣ.");
		assertBad("ηνωμένες πολιτείες");
		assertBad("ηνωμένες Πολιτείες");	
		assertBad("Ηνωμένες πολιτείες");

		RuleMatch[] matches1 = assertBad("Κατοικώ στις Ηνωμένες πολιτείες.");
		assertThat(matches1[0].getFromPos(), is(13));
		assertThat(matches1[0].getToPos(), is(31));
		assertThat(matches1[0].getSuggestedReplacements().toString(), is("[Ηνωμένες Πολιτείες]"));
		assertThat(matches1[0].getMessage(), is("If the term is a proper noun, use initial capitals."));

		RuleMatch[] matches3 = assertBad("Κατοικώ στις Ηνωμένες  πολιτείες."); // note the two spaces
		assertThat(matches3[0].getFromPos(), is(13));
		assertThat(matches3[0].getToPos(), is(32));
	}

	private void assertGood(String input) throws IOException {
		assertThat(rule.match(lt.getAnalyzedSentence(input)).length, is(0));
	}

	private RuleMatch[] assertBad(String input) throws IOException {
		RuleMatch[] matches = rule.match(lt.getAnalyzedSentence(input));
		assertThat(matches.length, is(1));
		return matches;
	}
}

@@ -2033,58 +2033,88 @@
 is(%22
-If the term is a proper noun, use initial capitals
+%CE%9F%CE%B9 %CE%BB%CE%AD%CE%BE%CE%B5%CE%B9%CF%82 %CF%84%CE%B7%CF%82 %CF%83%CF%85%CE%B3%CE%BA%CE%B5%CE%BA%CF%81%CE%B9%CE%BC%CE%AD%CE%BD%CE%B7%CF%82 %CE%AD%CE%BA%CF%86%CF%81%CE%B1%CF%83%CE%B7%CF%82 %CF%87%CF%81%CE%B5%CE%AF%CE%B1%CE%B6%CE%B5%CF%84%CE%B1%CE%B9 %CE%BD%CE%B1 %CE%BE%CE%B5%CE%BA%CE%B9%CE%BD%CE%BF%CF%8D%CE%BD %CE%BC%CE%B5 %CE%BA%CE%B5%CF%86%CE%B1%CE%BB%CE%B1%CE%AF%CE%B1 %CE%B3%CF%81%CE%AC%CE%BC%CE%BC%CE%B1%CF%84%CE%B1
 .%22))

Update a message in JUnit test of SpecificCaseRule