Examples of DSLMappingEntry


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( NL );
        sb.append( "- type1 is ClientServiceType.TypeGOLD" ).append( NL );
        sb.append( "- type2 is_not ClientServiceType.TypeGOLD" ).append( NL );
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

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

    private void validate(FileEditorInput input) {
        removeProblemsFor( input.getFile() );
        List errs = new ArrayList();
        for ( Iterator iter = model.getEntries().iterator(); iter.hasNext(); ) {
            DSLMappingEntry item = (DSLMappingEntry) iter.next();
            errs.addAll( item.getErrors() );
        }
        if ( errs.size() > 0 ) {
            for ( Iterator iter = errs.iterator(); iter.hasNext(); ) {
                MappingError mapEr = (MappingError) iter.next();
                createMarker( input.getFile(),
View Full Code Here

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

            public void widgetDefaultSelected(SelectionEvent e) {
                populate();
            }

            private void populate() {
                DSLMappingEntry selected = getCurrentSelected();
                exprText.setText( selected.getMappingKey() );
                mappingText.setText( selected.getMappingValue() );
                objText.setText( selected.getMetaData().getMetaData() == null ? "" : selected.getMetaData().getMetaData() );
            }

        } );

        //double click support
View Full Code Here

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

        } );
    }

    private void showEditPopup() {
        DSLMappingEntry selected = getCurrentSelected();
        if (selected != null) {
            MappingEditor editor = new MappingEditor( getSite().getShell() );
            editor.create();
            editor.getShell().setText( "Edit language mapping" );
            editor.setTitle( "Edit an existing language mapping item." );
            editor.setTitleImage( getTitleImage() );

            editor.setNLMappingItem( selected );

            editor.open();
            if ( !editor.isCancelled() ) {
                refreshModel();
                makeDirty();
                exprText.setText(selected.getMappingKey());
                mappingText.setText(selected.getMappingValue());
                objText.setText(selected.getMetaData().getMetaData() == null ? "" : selected.getMetaData().getMetaData());
            }
        }
    }
View Full Code Here

Examples of org.drools.lang.dsl.DSLMappingEntry

        SuggestionCompletionLoader suggestionCompletionLoader = new SuggestionCompletionLoader();
        ArrayList<DSLTokenizedMappingFile> dsls = new ArrayList<DSLTokenizedMappingFile>();

        DSLTokenizedMappingFile dslTokenizedMappingFile = new DSLTokenizedMappingFile();

        DSLMappingEntry dslMappingEntry = mock( DSLMappingEntry.class );
        when( dslMappingEntry.getSection() ).thenReturn( DSLMappingEntry.ANY );

        dslTokenizedMappingFile.getMapping().addEntry( dslMappingEntry );
        dsls.add( dslTokenizedMappingFile );

        SuggestionCompletionEngine suggestionEngine = suggestionCompletionLoader.getSuggestionEngine( "",
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.