use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.Pattern52FactPatternAdaptor in project drools by kiegroup.
the class BRLRuleModelTest method testDecisionTableColumnsWithLHSBoundFacts.
@Test
public void testDecisionTableColumnsWithLHSBoundFacts() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
Pattern52 p1 = new Pattern52();
p1.setFactType("Driver");
p1.setBoundName("$p1");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setBinding("$c1");
p1.getChildColumns().add(c1);
dt.getConditions().add(p1);
BRLConditionColumn brlCondition = new BRLConditionColumn();
FactPattern fp = new FactPattern("Driver");
fp.setBoundName("$brl1");
SingleFieldConstraint sfc1 = new SingleFieldConstraint();
sfc1.setFieldBinding("$sfc1");
sfc1.setOperator("==");
sfc1.setFactType("Driver");
sfc1.setFieldName("name");
sfc1.setFieldType(DataType.TYPE_STRING);
fp.addConstraint(sfc1);
brlCondition.getDefinition().add(fp);
dt.getConditions().add(brlCondition);
ActionInsertFactCol52 ins = new ActionInsertFactCol52();
ins.setBoundName("$ins");
ins.setFactField("rating");
ins.setFactType("Person");
ins.setType(DataType.TYPE_STRING);
dt.getActionCols().add(ins);
BRLRuleModel model = new BRLRuleModel(dt);
assertNotNull(model.getLHSBoundFacts());
assertEquals(2, model.getLHSBoundFacts().size());
assertTrue(model.getLHSBoundFacts().contains("$p1"));
assertTrue(model.getLHSBoundFacts().contains("$brl1"));
assertNotNull(model.getLHSBindingType("$p1"));
assertEquals("Driver", model.getLHSBindingType("$p1"));
assertNotNull(model.getLHSBindingType("$brl1"));
assertEquals("Driver", model.getLHSBindingType("$brl1"));
FactPattern r1 = model.getLHSBoundFact("$p1");
assertNotNull(r1);
assertTrue(r1 instanceof Pattern52FactPatternAdaptor);
Pattern52FactPatternAdaptor raif1 = (Pattern52FactPatternAdaptor) r1;
assertEquals("Driver", raif1.getFactType());
FactPattern r2 = model.getLHSBoundFact("$brl1");
assertNotNull(r2);
assertEquals("Driver", r2.getFactType());
}
use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.Pattern52FactPatternAdaptor in project drools by kiegroup.
the class BRLRuleModelTest method testRuleModelLHSBoundFacts.
@Test
public void testRuleModelLHSBoundFacts() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
// Setup Decision Table columns
Pattern52 p1 = new Pattern52();
p1.setFactType("Driver");
p1.setBoundName("$p1");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setBinding("$c1");
p1.getChildColumns().add(c1);
dt.getConditions().add(p1);
// Setup RuleModel columns (new BRLConditionColumn being added)
BRLRuleModel model = new BRLRuleModel(dt);
FactPattern fp = new FactPattern("Driver");
fp.setBoundName("$brl1");
SingleFieldConstraint sfc1 = new SingleFieldConstraint();
sfc1.setFieldBinding("$sfc1");
sfc1.setOperator("==");
sfc1.setFactType("Driver");
sfc1.setFieldName("name");
sfc1.setFieldType(DataType.TYPE_STRING);
fp.addConstraint(sfc1);
model.addLhsItem(fp);
// Checks
assertNotNull(model.getLHSBoundFacts());
assertEquals(2, model.getLHSBoundFacts().size());
assertTrue(model.getLHSBoundFacts().contains("$p1"));
assertTrue(model.getLHSBoundFacts().contains("$brl1"));
assertNotNull(model.getLHSBindingType("$p1"));
assertEquals("Driver", model.getLHSBindingType("$p1"));
assertNotNull(model.getLHSBindingType("$brl1"));
assertEquals("Driver", model.getLHSBindingType("$brl1"));
FactPattern r1 = model.getLHSBoundFact("$p1");
assertNotNull(r1);
assertTrue(r1 instanceof Pattern52FactPatternAdaptor);
Pattern52FactPatternAdaptor raif1 = (Pattern52FactPatternAdaptor) r1;
assertEquals("Driver", raif1.getFactType());
FactPattern r2 = model.getLHSBoundFact("$brl1");
assertNotNull(r2);
assertEquals("Driver", r2.getFactType());
}
use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.Pattern52FactPatternAdaptor in project drools by kiegroup.
the class BRLRuleModelTest method testRuleModelLHSBoundFacts_NoDuplicates.
@Test
public void testRuleModelLHSBoundFacts_NoDuplicates() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
// Setup Decision Table columns (with existing BRLConditionColumn)
Pattern52 p1 = new Pattern52();
p1.setFactType("Driver");
p1.setBoundName("$p1");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setBinding("$c1");
p1.getChildColumns().add(c1);
dt.getConditions().add(p1);
BRLConditionColumn brlCondition = new BRLConditionColumn();
FactPattern fp1 = new FactPattern("Driver");
fp1.setBoundName("$brl1");
SingleFieldConstraint sfc1 = new SingleFieldConstraint();
sfc1.setFieldBinding("$sfc1");
sfc1.setOperator("==");
sfc1.setFactType("Driver");
sfc1.setFieldName("name");
sfc1.setFieldType(DataType.TYPE_STRING);
fp1.addConstraint(sfc1);
brlCondition.getDefinition().add(fp1);
dt.getConditions().add(brlCondition);
// Setup RuleModel columns (existing BRLConditionColumn being edited)
BRLRuleModel model = new BRLRuleModel(dt);
FactPattern fp2 = new FactPattern("Driver");
fp2.setBoundName("$brl1");
SingleFieldConstraint sfc2 = new SingleFieldConstraint();
sfc2.setFieldBinding("$sfc1");
sfc2.setOperator("==");
sfc2.setFactType("Driver");
sfc2.setFieldName("name");
sfc2.setFieldType(DataType.TYPE_STRING);
fp2.addConstraint(sfc2);
model.addLhsItem(fp2);
// Checks
assertNotNull(model.getLHSBoundFacts());
assertEquals(2, model.getLHSBoundFacts().size());
assertTrue(model.getLHSBoundFacts().contains("$p1"));
assertTrue(model.getLHSBoundFacts().contains("$brl1"));
assertNotNull(model.getLHSBindingType("$p1"));
assertEquals("Driver", model.getLHSBindingType("$p1"));
assertNotNull(model.getLHSBindingType("$brl1"));
assertEquals("Driver", model.getLHSBindingType("$brl1"));
FactPattern r1 = model.getLHSBoundFact("$p1");
assertNotNull(r1);
assertTrue(r1 instanceof Pattern52FactPatternAdaptor);
Pattern52FactPatternAdaptor raif1 = (Pattern52FactPatternAdaptor) r1;
assertEquals("Driver", raif1.getFactType());
FactPattern r2 = model.getLHSBoundFact("$brl1");
assertNotNull(r2);
assertEquals("Driver", r2.getFactType());
}
Aggregations