protected String marshalRule( final RuleModel model ) { boolean isDSLEnhanced = model.hasDSLSentences(); bindingsPatterns = new HashMap<String, IFactPattern>(); bindingsFields = new HashMap<String, FieldConstraint>(); StringBuilder buf = new StringBuilder(); //Build rule this.marshalPackageHeader( model, buf ); this.marshalRuleHeader( model, buf ); this.marshalMetadata( buf, model ); this.marshalAttributes( buf, model ); buf.append( "\twhen\n" ); this.marshalLHS( buf, model, isDSLEnhanced ); buf.append( "\tthen\n" ); this.marshalRHS( buf, model, isDSLEnhanced ); this.marshalFooter( buf ); return buf.toString(); }
@Test public void testIsDSLEnhanced() throws Exception { RuleModel m = new RuleModel(); assertFalse( m.hasDSLSentences() ); m.addLhsItem( new FactPattern() ); assertFalse( m.hasDSLSentences() ); m.addRhsItem( new ActionSetField( "q" ) ); assertFalse( m.hasDSLSentences() ); m.addLhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m.addRhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m = new RuleModel(); m.addLhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); m = new RuleModel(); m.addRhsItem( new DSLSentence() ); assertTrue( m.hasDSLSentences() ); }