Package org.drools.compiler.lang.dsl

Examples of org.drools.compiler.lang.dsl.DefaultExpander.expand()


        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


            final String rule = "rule \"x\"\nwhen\n" + LHS + "\nthen\nTEST\nend";

            DefaultExpander de = new DefaultExpander();
            de.addDSLMapping(this.file.getMapping());
                   
            final String ruleAfterExpansion = de.expand(rule);
           
            final String expected = "rule \"x\"\nwhen\nAAAA( cd1 == 1041, cd2 != ( 1034 + 1035 ))\nthen\nSystem.out.println(\"DO_SOMETHING\");\nend";
           
            assertEquals( expected, ruleAfterExpansion );
           
View Full Code Here

            String expected = "rule x\nwhen\nthen\nmodify(policy) {price = 300}\nend\n";
           
            DefaultExpander de = new DefaultExpander();
            de.addDSLMapping( this.file.getMapping() );

            final String result = de.expand( input );
           
//            String result = entry.getKeyPattern().matcher( input ).replaceAll( entry.getValuePattern() );
           
            assertEquals( expected,
                          result );
View Full Code Here

            final String rule = "rule \"x\"\nwhen\n" + LHS + "\nthen\nend";

            DefaultExpander de = new DefaultExpander();
            de.addDSLMapping( this.file.getMapping() );

            final String ruleAfterExpansion = de.expand( rule );

            final String expected = "rule \"x\"\nwhen\nAAAA( cd1 == 1041, cd2 != ( 1034 + 1035 ))\nthen\nend";

            assertEquals( expected,
                          ruleAfterExpansion );
View Full Code Here

            final String rule = "rule \"x\"\nwhen\n" + LHS + "\nthen\nTEST\nend";

            DefaultExpander de = new DefaultExpander();
            de.addDSLMapping( this.file.getMapping() );

            final String ruleAfterExpansion = de.expand( rule );

            final String expected = "rule \"x\"\nwhen\nAAAA( cd1 == 1041, cd2 != ( 1034 + 1035 ))\nthen\nSystem.out.println(\"DO_SOMETHING\");\nend";

            assertEquals( expected,
                          ruleAfterExpansion );
View Full Code Here

        }
       
        DefaultExpander ex = new DefaultExpander();
        ex.addDSLMapping( tokenizedFile.getMapping() );
       
        System.err.println(ex.expand( "rule 'x' \n when \n address is present where name is \"foo\" and age is \"32\" \n then \n end" ));
    }

    @Test
    public void testSimple() throws Exception{
        String input = "u : User() and exists (a: Address( where name is \"foo\" and age is \"32\" ) from u.addresses)";
View Full Code Here

        try {
            if (expander == null) {
                expander = new DefaultExpander();
            }
            reader = resource.getReader();
            String str = expander.expand(reader);
            if (expander.hasErrors()) {
                for (ExpanderException error : expander.getErrors()) {
                    error.setResource(resource);
                    addBuilderResult(error);
                }
View Full Code Here

        for( String str: strs ){
            sb.append( "String is \"" + str + "\"\n" );
        }
        sb.append( "then\n" + "end\n" );
        String dslr = sb.toString();
        String drl = ex.expand( dslr );
       
        for( String str: strs ){
            assertTrue( drl.contains( '"' + str + '"' ) );
        }
    }
View Full Code Here

        sb.append( "- type1 is ClientServiceType.TypeGOLD" ).append( "\n" );
        sb.append( "- type2 is_not ClientServiceType.TypeGOLD" ).append( "\n" );
        sb.append( "- type3 is not ClientServiceType.TypeGOLD" ).append( "\n" );
        sb.append( "then\n" ).append( "end\n" );
        String dslr = sb.toString();
        String drl = ex.expand( dslr );
        System.out.println( dslr );
        System.out.println( drl );
        assertTrue( "failure type1", drl.contains( "type1 == ClientServiceType.TypeGOLD" ) );
        assertTrue( "failure type2", drl.contains( "type2 != ClientServiceType.TypeGOLD" ) );
        assertTrue( "failure type3", drl.contains( "type3 != ClientServiceType.TypeGOLD" ) );
View Full Code Here

        sb.append( "When the credit rating is 555" ).append( "\n" );
        sb.append( "This is a sentence with line breaks" ).append( "\n" );
        sb.append( "Bedingung-#19-MKM4" ).append( "\n" );
        sb.append( "then\n" + "end\n" );
        String dslr = sb.toString();
        String drl = ex.expand( dslr );

        for( String exp: new String[]{
                "name in ( 'Edson', 'Bob' )",
                "Person( attribute == \"handsome\" )",
                "Sentence( mykey == myvalue )",
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.