repo.save();
RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
RuleAsset rule = repositoryAssetService.loadRuleAsset( asset.getUUID() );
// check its all OK
BuilderResult result = repositoryAssetService.validateAsset( rule );
assertTrue(result.getLines().isEmpty());
RuleBaseCache.getInstance().clearCache();
// try it with a bad rule
RuleContentText text = new RuleContentText();
text.content = "rule 'MyBadRule' \n when Personx() then System.err.println(42); \n end";
rule.content= text;
result = repositoryAssetService.validateAsset( rule );
assertNotNull( result );
assertNotNull( result.getLines().get( 0 ).getMessage() );
assertEquals( AssetFormats.DRL,
result.getLines().get( 0 ).getAssetFormat() );
// now mix in a DSL
AssetItem dsl = pkg.addAsset( "MyDSL",
"" );
dsl.updateFormat( AssetFormats.DSL );
dsl.updateContent( "[when]There is a person=Person()\n[then]print out 42=System.err.println(42);" );
dsl.checkin( "" );
AssetItem dslRule = pkg.addAsset( "dslRule",
"" );
dslRule.updateFormat( AssetFormats.DSL_TEMPLATE_RULE );
dslRule.updateContent( "when \n There is a person \n then \n print out 42" );
dslRule.checkin( "" );
rule = repositoryAssetService.loadRuleAsset( dslRule.getUUID() );
result = repositoryAssetService.validateAsset( rule );
assertTrue(result.getLines().isEmpty());
asset = pkg.addAsset( "someEnumThing",
"" );
asset.updateFormat( AssetFormats.ENUMERATION );
asset.updateContent( "goober boy" );
asset.checkin( "" );
result = repositoryAssetService.validateAsset( repositoryAssetService.loadRuleAsset( asset.getUUID() ) );
assertFalse( result.getLines().size() == 0 );
}