Package org.drools.compiler.lang.dsl

Examples of org.drools.compiler.lang.dsl.DSLTokenizedMappingFile.parseAndLoad()


    private void checkExpansion(String source, String expected) throws Exception {
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]There is an TestObject=TestObject()\n"
                + "[when]-startDate is before {date}=startDate>DateUtils.parseDate(\"{date}\")\n"
                + "[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());
View Full Code Here


        String expected = "query \"isMature\"\n" +
                "Person(age  >  18)\n" +
                "end\n";

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

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());
View Full Code Here

                "     when\n" +
                "         System.out.println(Bojan Oklahoma and NJ,Andrew AMW Test)\n" +
                "     then\n" +
                "end";

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

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping(file.getMapping());
View Full Code Here

    @Test(timeout = 1000)
    public void testExpandInfiniteLoop() throws Exception {
        // DROOLS-73
        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";
View Full Code Here

                        "        System.out.println(\"Your First Rule\");\n" +
                        "\n" +
                        "end\n";

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

        DefaultExpander ex = new DefaultExpander();
View Full Code Here

                        + "then\n"
                        + "list.add(\"X\");\n"
                        + "end\n";

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

        DefaultExpander ex = new DefaultExpander();
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

    @Test
    public void testANTLRLineNumberError() throws Exception {
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]foo=Foo()" + NL + "[then]bar {num}=baz({num});";
        file.parseAndLoad( new StringReader( dsl ) );

        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping( file.getMapping() );
        String source = "rule 'q'" + NL + "agenda-group 'x'" + NL + "when" + NL + "    __  " + NL +
                "then" + NL + "    bar 42" + NL + "\tgoober" + NL + "end";
View Full Code Here

    @Test
    public void testANTLREnumExpand() throws Exception {
        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";
View Full Code Here

    private void checkExpansion(String source, String expected) throws Exception {
        DSLTokenizedMappingFile file = new DSLTokenizedMappingFile();
        String dsl = "[when]There is an TestObject=TestObject()\n"
                + "[when]-startDate is before {date}=startDate>DateUtils.parseDate(\"{date}\")\n"
                + "[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() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.