Package org.drools.compiler.lang.dsl

Examples of org.drools.compiler.lang.dsl.DefaultExpander


        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]When the credit rating is {rating:ENUM:Applicant.creditRating} = applicant:Applicant(credit=={rating})";
        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0,
                file.getErrors().size());
        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());
        String source = "rule \"TestNewDslSetup\"\ndialect \"mvel\"\nwhen\nWhen the credit rating is AA\nthen \nend";

        //        String source="rule \"TestNewDslSetup\"\n"+
        //                        "dialect \"mvel\"\n"+
        //                        "when\n"+
        //                            "When the credit rating is OK\n"+
        //                        "then\n"+
        //                        "end\n";

        String drl = ex.expand(source);

        String expected = "rule \"TestNewDslSetup\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "applicant:Applicant(credit==AA)\n" +
                "then  \nend";

        assertFalse(ex.getErrors().toString(),
                ex.hasErrors());
        assertEquals(expected,
                drl);

        //System.err.println(ex.expand( "rule 'x' \n when \n foo \n then \n end" ));
    }
View Full Code Here


                + "[when]-endDate is after {date}=endDate>DateUtils.parseDate(\"{date}\")";
        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0,
                file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());

        String drl = ex.expand(source);
        assertFalse(ex.hasErrors());

        assertEquals(expected, drl);
    }
View Full Code Here

        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0,
                file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());

        String drl = ex.expand(source);
        assertFalse(ex.hasErrors());

        assertEquals(expected, drl);
    }
View Full Code Here

        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0,
                file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());

        String drl = ex.expand(source);

        assertFalse(ex.hasErrors());

        assertEquals(expected, drl);
    }
View Full Code Here

        DSLMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]Foo with {var} bars=Foo( bars == {var} )";
        file.parseAndLoad(new StringReader(dsl));
        assertEquals(0, file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());
        String source = "rule 'dsl rule'\nwhen\n Foo with {var} bars\nthen\n\nend";
        ex.expand(source);
        assertFalse(ex.hasErrors());
    }
View Full Code Here

        file.parseAndLoad(new StringReader(dsl));
        assertEquals(file.getErrors().toString(),
                0,
                file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());

        String drl = ex.expand(source);
        assertFalse(ex.hasErrors());

        assertEquals(expected, drl);
    }
View Full Code Here

        file.parseAndLoad(new StringReader(dsl));
        assertEquals(file.getErrors().toString(),
                0,
                file.getErrors().size());

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());

        String drl = ex.expand(source);
        assertFalse(ex.hasErrors());

        assertEquals(expected, drl);
    }
View Full Code Here

        DefaultExpanderResolver resolver = new DefaultExpanderResolver(new StringReader(dsl));
       
       
        final DSLMappingFile file = new DSLTokenizedMappingFile();
        if ( file.parseAndLoad( new StringReader(dsl) ) ) {
            final Expander expander = new DefaultExpander();
            expander.addDSLMapping( file.getMapping() );
            resolver.addExpander("*", expander);
        } else {
            throw new RuntimeDroolsException( "Error parsing and loading DSL file." + file.getErrors() );
        }

View Full Code Here

        final Reader reader2 = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
        this.tokenizedFile.parseAndLoad( reader2 );
        reader2.close();

        this.expander = new DefaultExpander();
    }
View Full Code Here

        DSLMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
        file.parseAndLoad( new StringReader( dsl ) );
        assertEquals( 0,
                      file.getErrors().size() );
        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping( file.getMapping() );

        //System.err.println(ex.expand( "rule 'x' \n when \n foo \n then \n end" ));
    }
View Full Code Here

TOP

Related Classes of org.drools.compiler.lang.dsl.DefaultExpander

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.