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>"));
}
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>"));
}
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>"));
}
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);
}
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) {
}
}
Aggregations