}
@Test
public void testBRXMLWithDSLMixedIn() throws Exception {
ServiceImplementation serviceImplementation = getServiceImplementation();
RulesRepository repo = serviceImplementation.getRulesRepository();
//create our package
PackageItem pkg = repo.createPackage("testBRLWithDSLMixedIn",
"");
DroolsHeader.updateDroolsHeader("import org.drools.Person",
pkg);
AssetItem rule1 = pkg.addAsset("rule2",
"");
rule1.updateFormat(AssetFormats.BUSINESS_RULE);
AssetItem dsl = pkg.addAsset("MyDSL",
"");
dsl.updateFormat(AssetFormats.DSL);
dsl.updateContent("[when]This is a sentence=Person()\n[then]say {hello}=System.err.println({hello});");
dsl.checkin("");
RuleModel model = new RuleModel();
model.name = "rule2";
FactPattern pattern = new FactPattern("Person");
pattern.setBoundName("p");
ActionSetField action = new ActionSetField("p");
ActionFieldValue value = new ActionFieldValue("age",
"42",
SuggestionCompletionEngine.TYPE_NUMERIC);
action.addFieldValue(value);
model.addLhsItem(pattern);
model.addRhsItem(action);
DSLSentence dslCondition = new DSLSentence();
dslCondition.setDefinition( "This is a sentence" );
model.addLhsItem(dslCondition);
DSLSentence dslAction = new DSLSentence();
dslAction.setDefinition( "say {42}" );
model.addRhsItem(dslAction);
rule1.updateContent(BRXMLPersistence.getInstance().marshal(model));
rule1.checkin("");
repo.save();
//now add a rule with no DSL
model = new RuleModel();
model.name = "ruleNODSL";
pattern = new FactPattern("Person");
pattern.setBoundName("p");
action = new ActionSetField("p");
value = new ActionFieldValue("age",
"42",
SuggestionCompletionEngine.TYPE_NUMERIC);
action.addFieldValue(value);
model.addLhsItem(pattern);
model.addRhsItem(action);
AssetItem ruleNODSL = pkg.addAsset("ruleNoDSL",
"");
ruleNODSL.updateFormat(AssetFormats.BUSINESS_RULE);
ruleNODSL.updateContent(BRXMLPersistence.getInstance().marshal(model));
ruleNODSL.checkin("");
pkg = repo.loadPackage("testBRLWithDSLMixedIn");
PackageAssembler asm = new PackageAssembler(pkg);
asm.compile();
assertFalse(asm.hasErrors());
Package[] binPkgs = asm.getBinaryPackage();