Search in sources :

Example 11 with Demo

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

the class PatternRuleXmlCreatorTest method testToXMLWithRuleGroupAndSubId2.

@Test
public void testToXMLWithRuleGroupAndSubId2() {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore", "2");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertFalse(xml.contains("<rulegroup id=\"test_spacebefore\""));
    assertFalse(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<message>This is a dummy message 2.</message>"));
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 12 with Demo

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

the class PatternRuleXmlCreatorTest method testToXMLWithRuleGroup.

@Test
public void testToXMLWithRuleGroup() {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertTrue(xml.contains("<rulegroup id=\"test_spacebefore\""));
    assertTrue(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<rule>"));
    assertTrue(xml.contains("<rule type=\"duplication\">"));
    assertTrue(xml.contains("<token>blah</token>"));
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 13 with Demo

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

the class PatternRuleXmlCreatorTest method testToXMLWithRuleGroupAndSubId1.

@Test
public void testToXMLWithRuleGroupAndSubId1() {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore", "1");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertFalse(xml.contains("<rulegroup"));
    assertFalse(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<message>This is a dummy message 1.</message>"));
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 14 with Demo

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

the class PatternRuleXmlCreatorTest method testToXML.

@Test
public void testToXML() throws IOException {
    PatternRuleId ruleId = new PatternRuleId("DEMO_RULE");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertEquals("<rule id=\"DEMO_RULE\" name=\"Find 'foo bar'\"><!-- a trivial demo rule that matches \"foo\" followed by \"bar\" -->\n" + "  <pattern case_sensitive=\"no\">\n" + "    <token>foo</token>\n" + "    <token>bar</token>\n" + "  </pattern>\n" + "  <message>Did you mean <suggestion><match no=\"1\"/> fuu bah</suggestion>?</message>\n" + "  <url>http://fake-server.org/foo-bar-error-explained</url>\n" + "  <example>This is <marker>fuu bah</marker>.</example>\n" + "  <example correction=\"foo fuu bah\">This is <marker>foo bar</marker>.</example>\n" + "</rule>", xml);
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Example 15 with Demo

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

the class PatternRuleXmlCreatorTest method testToXMLInvalidRuleId.

@Test
public void testToXMLInvalidRuleId() {
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    PatternRuleId fakeRuleId = new PatternRuleId("FAKE_ID");
    try {
        creator.toXML(fakeRuleId, new Demo());
        fail();
    } catch (RuntimeException ignored) {
    }
}
Also used : Demo(org.languagetool.language.Demo) Test(org.junit.Test)

Aggregations

Demo (org.languagetool.language.Demo)15 Test (org.junit.Test)14 ByteArrayInputStream (java.io.ByteArrayInputStream)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Before (org.junit.Before)1 JLanguageTool (org.languagetool.JLanguageTool)1 ChunkTag (org.languagetool.chunking.ChunkTag)1 RuleMatch (org.languagetool.rules.RuleMatch)1 ManualSynthesizer (org.languagetool.synthesis.ManualSynthesizer)1 ManualSynthesizerAdapter (org.languagetool.synthesis.ManualSynthesizerAdapter)1 ManualTagger (org.languagetool.tagging.ManualTagger)1 ManualTaggerAdapter (org.languagetool.tokenizers.ManualTaggerAdapter)1