Examples of DSLMappingEntry


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

            assertTrue( this.file.getErrors().isEmpty() );

            assertEquals( 1,
                          this.file.getMapping().getEntries().size() );

            DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );

            assertEquals( DSLMappingEntry.CONDITION,
                          entry.getSection() );
            assertEquals( DSLMappingEntry.EMPTY_METADATA,
                          entry.getMetaData() );
            assertEquals( "something:={value}",
                          entry.getMappingKey() );
            assertEquals( "Attribute( something == \"{value}\" )",
                          entry.getMappingValue() );

        } catch ( final IOException e ) {
            e.printStackTrace();
            fail( "Should not raise exception " );
        }
View Full Code Here

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

            assertTrue( this.file.getErrors().isEmpty() );

            assertEquals( 1,
                          this.file.getMapping().getEntries().size() );

            DSLMappingEntry entry = (DSLMappingEntry) this.file.getMapping().getEntries().get( 0 );

            assertEquals( DSLMappingEntry.CONDITION,
                          entry.getSection() );
            assertEquals( DSLMappingEntry.EMPTY_METADATA,
                          entry.getMetaData() );
            System.out.println( entry.getValuePattern() );
            System.out.println( entry.getVariables() );
            assertEquals( "ATTRIBUTE {attr:ENUM:Attribute.value} in {list}",
                          entry.getMappingKey() );
            assertEquals( "Attribute( {attr} in ({list}) )",
                          entry.getMappingValue() );

            assertEquals( "(?:(?<=^)|(?<=\\W))ATTRIBUTE\\s+(.*?)\\s+in\\s+(.*?)$",
                          entry.getKeyPattern().toString() );

        } catch ( final IOException e ) {
            e.printStackTrace();
            fail( "Should not raise exception " );
        }
View Full Code Here

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

    private DSLMappingEntry createEntry(final String inputKey,
                                        final String inputValue) throws IOException {
        String mapping = "[condition][]" + inputKey + "=" + inputValue;
        StringReader dsl = new StringReader( mapping );
        DSLMappingEntry entry = null;
        try {
            DSLTokenizedMappingFile parser = new DSLTokenizedMappingFile();
            if ( parser.parseAndLoad( dsl ) ) {
                entry = parser.getMapping().getEntries().get( 0 );
            } else {
View Full Code Here

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

        final String inputValue = "Customer( name == \"{name}\", surname == \"{surname}\", money > $money )";

        final String expectedKeyP = lookbehind + "The\\s+Customer\\s+name\\s+is\\s+(.*?)\\s+and\\s+surname\\s+is\\s+(.*?)\\s+and\\s+it\\s+has\\s+US\\$\\s+50,00\\s+on\\s+his\\s+(.*?)$";
        final String expectedValP = "Customer( name == \"{name}\", surname == \"{surname}\", money > $money )";

        final DSLMappingEntry entry = createEntry( inputKey,
                                                   inputValue );

        assertEquals( inputKey,
                      entry.getMappingKey() );
        assertEquals( expectedKeyP,
                      entry.getKeyPattern().pattern() );
        assertEquals( inputValue,
                      entry.getMappingValue() );
        assertEquals( expectedValP,
                      entry.getValuePattern() );
    }
View Full Code Here

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

        final String inputValue = "name == \"{name}\"";

        final String expectedKeyP = lookbehind + "-\\s*name\\s+is\\s+(.*?)$";
        final String expectedValP = "name == \"{name}\"";

        final DSLMappingEntry entry = createEntry( inputKey,
                                                   inputValue );

        assertEquals( inputKey,
                      entry.getMappingKey() );
        assertEquals( expectedKeyP,
                      entry.getKeyPattern().pattern() );
        assertEquals( inputValue,
                      entry.getMappingValue() );
        assertEquals( expectedValP,
                      entry.getValuePattern() );

    }
View Full Code Here

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

        final String inputValue = "name == \"{name}\"";

        final String expectedKeyP = lookbehind + "-\\s*name\\s+is\\s+(.*?)$";
        final String expectedValP = "name == \"{name}\"";

        final DSLMappingEntry entry = createEntry( inputKey,
                                                   inputValue );

        assertEquals( inputKey,
                      entry.getMappingKey() );
        assertEquals( entry.getKeyPattern().pattern(),
                      expectedKeyP,
                      entry.getKeyPattern().pattern() );
        assertEquals( inputValue,
                      entry.getMappingValue() );
        assertEquals( expectedValP,
                      entry.getValuePattern() );
    }
View Full Code Here

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

    }
   

    @Test
    public void testExpandSpaces() throws IOException {
        DSLMappingEntry entry = this.setupEntry();
        DefaultExpander ex = makeExpander( entry );
        String[] strs = new String[]{ "0_sp", " 1_sp", "   3_sp", "0_sp_1 ",
                                      "0_sp_3   ", "0_sp 1_sp 2_sp", "   3_sp   3_sp 1_sp 1_sp_2  " };
        StringBuilder sb = new StringBuilder( "rule x\n" + "when\n" );
        for( String str: strs ){
View Full Code Here

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

        }
    }

    @Test
    public void testExpandWithDots() throws IOException {
        DSLMappingEntry entry1 = this.createEntry( "- {prop} is not {val} ", "{prop} != {val}" );
        DSLMappingEntry entry2 = this.createEntry( "- {prop} is {val} ",     "{prop} == {val}" );
        DSLMappingEntry entry3 = this.createEntry( "- {prop} is_not {val} ", "{prop} != {val}" );
        DefaultExpander ex = makeExpander( entry1, entry2, entry3 );
        StringBuilder sb = new StringBuilder( "rule x\n" ).append( "when\n" );
        sb.append( "> Foo()").append( "\n" );
        sb.append( "- type1 is ClientServiceType.TypeGOLD" ).append( "\n" );
        sb.append( "- type2 is_not ClientServiceType.TypeGOLD" ).append( "\n" );
View Full Code Here

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



    @Test
    public void testExpandWithBrackets() throws IOException {
        DSLMappingEntry entry1 = this.createEntry( "attr {attr_name} is in \\[ {values} \\]",
                                                   "{attr_name} in ( {values} )" );
        DSLMappingEntry entry2 = this.createEntry( "((H|h)e|(S|s)he) \\(is\\) (a|an) $xx {attribute} (man|woman)",
                                                   "Person( attribute == \"{attribute}\" )" );
        DSLMappingEntry entry3 = this.createEntry( "DSL sentence with {key1} {key2}",
                                                   "Sentence( {key1} == {key2} )" );
        DSLMappingEntry entry4 = this.createEntry( "When the credit rating is {rating:ENUM:Applicant.creditRating}",
                                                   "applicant:Applicant(credit=={rating})" );
        DSLMappingEntry entry5 = this.createEntry( "When the credit rating is {rating:regex:\\d{3}}",
                                                   "applicant:Applicant(credit=={rating})" );
       
        assertEquals( lookbehind + "When\\s+the\\s+credit\\s+rating\\s+is\\s+(\\d{3})(?=\\W|$)",
                      entry5.getKeyPattern().toString() );
        assertEquals( "applicant:Applicant(credit=={rating})",
                      entry5.getValuePattern() );

        DSLMappingEntry entry6 = this.createEntry( "This is a sentence with line breaks",
                                                   "Cheese\\n(price == 10)" );
       
        assertEquals( lookbehind + "This\\s+is\\s+a\\s+sentence\\s+with\\s+line\\s+breaks(?=\\W|$)",
                      entry6.getKeyPattern().toString() );
        assertEquals( "Cheese\n(price == 10)",
                      entry6.getValuePattern());

        DSLMappingEntry entry7 = this.createEntry( "Bedingung-\\#19-MKM4",
                                                   "eval ( $p.getTempVal(\"\\#UML-ATZ-1\") < $p.getZvUmlStfr() )" );
       
        assertEquals( lookbehind  + "Bedingung-#19-MKM4(?=\\W|$)",
                      entry7.getKeyPattern().toString() );
        assertEquals( "eval ( $p.getTempVal(\"#UML-ATZ-1\") < $p.getZvUmlStfr() )",
                       entry7.getValuePattern());
 
        DefaultExpander ex = makeExpander( entry1, entry2, entry3, entry4,
                                           entry5, entry6, entry7 );
        StringBuilder sb = new StringBuilder( "rule x\n" ).append( "when\n" );
       
View Full Code Here

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

   
    @Test
    public void testCreateWithTilde() throws IOException {
      //If the statement parses it passes. To test expressions in dsl with a ~
      try{
        DSLMappingEntry entry1 = this.createEntry( "the benefit HAS an EXACT message of {ALLMSG}",
                              "$benefit :Map(this['ALLMSG'] matches \"(?i).*~{ALLMSG}~.*\") from $benefits");
      }catch(Exception e){
        fail(e.getMessage());
      }

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.