use of org.drools.verifier.misc.DrlRuleParser in project drools by kiegroup.
the class EndPage method createContents.
public static List createContents(java.util.List<DrlRuleParser> rules) {
List index = new List(true);
for (DrlRuleParser drlRuleData : rules) {
Chunk chunk = new Chunk(drlRuleData.getName());
// chunk.setLocalGoto( item.getName() );
ListItem listItem = new ListItem(chunk);
index.add(listItem);
}
return index;
}
use of org.drools.verifier.misc.DrlRuleParser in project drools by kiegroup.
the class DrlRuleDataTest method testHandleDrl.
@Test
public void testHandleDrl() {
String drl = "rule \"Something\" \n ";
drl += "dialect \"Java\" \n ";
drl += " when \n ";
drl += " Person() \n ";
drl += " Cheesery() \n ";
drl += " then \n ";
drl += " insert( new Person()) \n ";
drl += " insert( new Car()) \n ";
drl += " insert( new Cheese()) \n ";
drl += "end ";
DrlRuleParser s = DrlRuleParser.findRulesDataFromDrl(drl).get(0);
assertEquals(1, s.getHeader().size());
assertEquals(2, s.getLhs().size());
assertEquals(3, s.getRhs().size());
assertEquals("", s.getDescription());
}
use of org.drools.verifier.misc.DrlRuleParser in project drools by kiegroup.
the class DrlRuleDataTest method testHandleDrlNoLineBreaks.
@Test
public void testHandleDrlNoLineBreaks() {
String drl = "rule \"CreditScoreApproval\" \n";
drl += " dialect \"mvel\" \n";
drl += " when then";
drl += " applicant.setApproved(true) \n";
drl += " applicant.setName( \"Toni\" ) \n";
drl += " applicant.setAge( 10 ) \n";
drl += "end";
DrlRuleParser s = DrlRuleParser.findRulesDataFromDrl(drl).get(0);
assertNotNull(s);
assertEquals(1, s.getHeader().size());
assertEquals(0, s.getLhs().size());
assertEquals(3, s.getRhs().size());
assertEquals("", s.getDescription());
}
use of org.drools.verifier.misc.DrlRuleParser in project drools by kiegroup.
the class DrlRuleDataTest method testHandleDrlWithComment.
@Test
public void testHandleDrlWithComment() {
String drl = "# Really important information about this rule \n";
drl += "# Another line because one was not enough \n";
drl += "# \n";
drl += "# @author: trikkola \n";
drl += "rule \"First\" \n";
drl += " dialect \"mvel\" \n";
drl += " when \n ";
drl += " Person() \n ";
drl += " Cheesery() \n ";
drl += " then \n ";
drl += " applicant.setApproved(true) \n";
drl += " applicant.setName( \"Toni\" ) \n";
drl += " applicant.setAge( 10 ) \n";
drl += "end \n";
drl += "\n";
drl += "# Really important information about this rule \n";
drl += "# Another line because one was not enough \n";
drl += "# \n";
drl += "# @author: trikkola \n";
drl += "# @created: 29.12.2001 \n";
drl += "# @edited: 5.5.2005 \n";
drl += "rule \"Second\" \n";
drl += " dialect \"mvel\" \n";
drl += " when \n ";
drl += " Person() \n ";
drl += " Cheesery() \n ";
drl += " then \n ";
drl += " applicant.setApproved(true) \n";
drl += " applicant.setName( \"Toni\" ) \n";
drl += " applicant.setAge( 10 ) \n";
drl += "end";
drl += "\n";
drl += "rule \"Third\" \n";
drl += " dialect \"mvel\" \n";
drl += " when \n ";
drl += " Person() \n ";
drl += " Cheesery() \n ";
drl += " then \n ";
drl += " applicant.setApproved(true) \n";
drl += " applicant.setName( \"Toni\" ) \n";
drl += " applicant.setAge( 10 ) \n";
drl += "end";
List<DrlRuleParser> list = DrlRuleParser.findRulesDataFromDrl(drl);
assertEquals(3, list.size());
DrlRuleParser rd = list.get(0);
assertNotNull(rd);
assertEquals(1, rd.getHeader().size());
assertEquals(2, rd.getLhs().size());
assertEquals(3, rd.getRhs().size());
assertEquals(1, rd.getMetadata().size());
assertNotNull(rd.getDescription());
assertNotSame("", rd.getDescription());
DrlRuleParser rd2 = list.get(1);
assertNotNull(rd2);
assertEquals(1, rd2.getHeader().size());
assertEquals(2, rd2.getLhs().size());
assertEquals(3, rd2.getRhs().size());
assertEquals(3, rd2.getMetadata().size());
assertNotNull(rd2.getDescription());
String description = "Really important information about this rule\n";
description += "Another line because one was not enough\n\n";
assertEquals(description, rd2.getDescription());
assertNotSame("", rd2.getDescription());
DrlRuleParser rd3 = list.get(2);
assertNotNull(rd3);
assertEquals(1, rd3.getHeader().size());
assertEquals(2, rd3.getLhs().size());
assertEquals(3, rd3.getRhs().size());
assertNotNull(rd3.getDescription());
assertEquals("", rd3.getDescription());
}
use of org.drools.verifier.misc.DrlRuleParser in project drools by kiegroup.
the class VerifierImpl method addDrlRulesData.
private void addDrlRulesData(List<DrlRuleParser> rules) {
for (DrlRuleParser rData : rules) {
VerifierRule rule = this.result.getVerifierData().getRuleByName(rData.getName());
if (rule != null) {
rule.getHeader().addAll(rData.getHeader());
rule.getLhsRows().addAll(rData.getLhs());
rule.getRhsRows().addAll(rData.getRhs());
rule.setDescription(rData.getDescription());
rule.getCommentMetadata().addAll(rData.getMetadata());
rule.getOtherInfo().putAll(rData.getOtherInformation());
}
}
}
Aggregations