Search in sources :

Example 1 with Belarusian

use of org.languagetool.language.Belarusian in project languagetool by languagetool-org.

the class ConfigurationTest method testSaveAndLoadConfigurationForManyLanguages.

@Test
public void testSaveAndLoadConfigurationForManyLanguages() throws Exception {
    File tempFile = File.createTempFile(ConfigurationTest.class.getSimpleName(), ".cfg");
    createConfiguration(tempFile, new AmericanEnglish());
    try {
        Configuration conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new AmericanEnglish());
        Set<String> disabledRuleIds = conf.getDisabledRuleIds();
        assertTrue(disabledRuleIds.contains("FOO1"));
        assertTrue(disabledRuleIds.contains("Foo2"));
        assertEquals(2, disabledRuleIds.size());
        Set<String> enabledRuleIds = conf.getEnabledRuleIds();
        assertTrue(enabledRuleIds.contains("enabledRule"));
        assertEquals(1, enabledRuleIds.size());
        //now change language
        conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new Belarusian());
        disabledRuleIds = conf.getDisabledRuleIds();
        assertTrue(disabledRuleIds.isEmpty());
        enabledRuleIds = conf.getEnabledRuleIds();
        assertTrue(enabledRuleIds.isEmpty());
        conf.setEnabledRuleIds(new HashSet<>(Arrays.asList("enabledBYRule")));
        conf.saveConfiguration(new Belarusian());
        //and back...
        conf = new Configuration(tempFile.getParentFile(), tempFile.getName(), new AmericanEnglish());
        disabledRuleIds = conf.getDisabledRuleIds();
        assertTrue(disabledRuleIds.contains("FOO1"));
        assertTrue(disabledRuleIds.contains("Foo2"));
        assertEquals(2, disabledRuleIds.size());
        enabledRuleIds = conf.getEnabledRuleIds();
        assertTrue(enabledRuleIds.contains("enabledRule"));
        assertEquals(1, enabledRuleIds.size());
    } finally {
        tempFile.delete();
    }
}
Also used : AmericanEnglish(org.languagetool.language.AmericanEnglish) Belarusian(org.languagetool.language.Belarusian) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 AmericanEnglish (org.languagetool.language.AmericanEnglish)1 Belarusian (org.languagetool.language.Belarusian)1