use of org.drools.workbench.models.datamodel.rule.RuleModel in project drools by kiegroup.
the class PluggableIActionTest method marshalPluggableIAction.
@Test
public void marshalPluggableIAction() {
RuleModel ruleModel = new RuleModel();
ruleModel.name = "TestIAction rule";
ruleModel.addRhsItem(new TestIAction());
String marshaledString = RuleModelDRLPersistenceImpl.getInstance().marshal(ruleModel);
assertEquals(DRL_RULE, marshaledString);
}
use of org.drools.workbench.models.datamodel.rule.RuleModel in project drools by kiegroup.
the class RuleModelDRLPersistenceExtensionsTest method unmarshalWithExtensions.
@Test
public void unmarshalWithExtensions() {
RuleModel ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshal(DRL_RULE, Collections.emptyList(), new PackageDataModelOracleImpl(), Arrays.asList(new TestIActionPersistenceExtension()));
assertEquals(1, ruleModel.rhs.length);
IAction iAction = ruleModel.rhs[0];
assertTrue(iAction instanceof TestIAction);
}
use of org.drools.workbench.models.datamodel.rule.RuleModel in project drools by kiegroup.
the class RuleModelDRLPersistenceExtensionsTest method unmarshalDSLWithoutExtensions.
@Test
public void unmarshalDSLWithoutExtensions() {
RuleModel ruleModel = RuleModelDRLPersistenceImpl.getInstance().unmarshalUsingDSL(DSL_RULE, Collections.emptyList(), new PackageDataModelOracleImpl());
assertEquals(1, ruleModel.rhs.length);
IAction iAction = ruleModel.rhs[0];
assertTrue(iAction instanceof FreeFormLine);
}
use of org.drools.workbench.models.datamodel.rule.RuleModel in project drools by kiegroup.
the class RuleModelDRLPersistenceTest method testNotSoundsLikeAndNotMatchesInDsl.
@Test
public void testNotSoundsLikeAndNotMatchesInDsl() {
final String dslDefinition = "There is Person that field not matches and not soundslike {name}";
final String drl = "Person( field not soundslike \"{name}\" && field not matches \"{name}\" )";
final String dslFile = "[when]" + dslDefinition + "=" + drl;
final String drlWithDsl = "rule \"with dsl\"\n" + "\tdialect \"mvel\"\n" + " when\n" + dslDefinition.replace("{name}", "John") + "\n" + "then\n" + "end\n";
final RuleModel model = ruleModelPersistence.unmarshalUsingDSL(drlWithDsl, null, dmo, dslFile);
final DSLSentence dslSentence = (DSLSentence) model.lhs[0];
assertEquals(dslDefinition, dslSentence.getDefinition());
assertEquals(drl, dslSentence.getDrl());
assertEquals("John", dslSentence.getValues().get(0).getValue());
}
use of org.drools.workbench.models.datamodel.rule.RuleModel in project drools by kiegroup.
the class RuleModelDRLPersistenceTest method testIncompleteFieldConstraintStringWithNonNull.
@Test
public void testIncompleteFieldConstraintStringWithNonNull() {
String expected = "" + "rule \"rule\" \n" + " dialect \"mvel\"\n" + " when\n" + " Message( text == \"\" )\n" + " then\n" + "end\n";
final RuleModel m = new RuleModel();
m.name = "rule";
final FactPattern pat = new FactPattern("Message");
m.addLhsItem(pat);
final SingleFieldConstraint con = new SingleFieldConstraint();
con.setFieldName("text");
con.setOperator("==");
con.setValue("");
con.setFieldType(DataType.TYPE_STRING);
con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
pat.addConstraint(con);
checkMarshalling(expected, m);
}
Aggregations