Package org.drools.ide.common.server.rules

Examples of org.drools.ide.common.server.rules.SuggestionCompletionLoader$FieldInfo


    @Test
    public void testDataEnums3() {
        String pkg = "package org.test\n import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngineTest.NestedClass";

        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();

        List<String> enums = new ArrayList<String>();

        enums.add( "'Fact.f1' : ['a1', 'a2'] \n 'Fact.f2' : ['def1', 'def2', 'def3'] \n 'Fact.f2[f1=a2]' : ['c1', 'c2']" );

        SuggestionCompletionEngine engine = loader.getSuggestionEngine( pkg,
                                                                        new ArrayList<JarInputStream>(),
                                                                        new ArrayList<DSLTokenizedMappingFile>(),
                                                                        enums );
        assertEquals( "String",
                      engine.getFieldType( "NestedClass",
View Full Code Here


    @Test
    public void testNestedEnums() {
        String pkg = "package org.test\n import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngineTest.NestedEnum";

        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();

        SuggestionCompletionEngine engine = loader.getSuggestionEngine( pkg,
                                                                        new ArrayList<JarInputStream>(),
                                                                        new ArrayList<DSLTokenizedMappingFile>(),
                                                                        new ArrayList<String>() );
        assertEquals( "Comparable",
                      engine.getFieldType( "NestedEnum",
View Full Code Here

   
    @Test
    public void testNestedEnumsFieldLookup() {
        String pkg = "package org.test\n import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngineTest.NestedEnum";

        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();

        SuggestionCompletionEngine engine = loader.getSuggestionEngine( pkg,
                                                                        new ArrayList<JarInputStream>(),
                                                                        new ArrayList<DSLTokenizedMappingFile>(),
                                                                        new ArrayList<String>() );
        assertEquals( "Comparable",
                      engine.getFieldType( "NestedEnum",
View Full Code Here

    }

    @Test
    public void testStripUnNeededFields() {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        List<String> result = loader.removeIrrelevantFields( Arrays.asList( new String[]{"foo", "toString", "class", "hashCode"} ) );
        assertEquals( 1,
                      result.size());
        assertEquals( "foo",
                      result.get( 0 ) );
    }
View Full Code Here

                      result.get( 0 ) );
    }

    @Test
    public void testGetShortNameOfClass() {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();

        assertEquals( "Object",
                      loader.getShortNameOfClass( Object.class.getName() ) );

        assertEquals( "Foo",
                      loader.getShortNameOfClass( "Foo" ) );
    }
View Full Code Here

public class SuggestionCompletionLoaderTest {

    @Test
    public void testSuggestionCompLoader() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.Person",
                                                                     new ArrayList(),
                                                                     new ArrayList() );
        assertNotNull( eng );

    }
View Full Code Here

    }

    @Test
    public void testSuggestionCompLoaderWithExtraImportProviders() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        loader.addExternalImportDescrProvider( new SuggestionCompletionLoader.ExternalImportDescrProvider() {

            public Set<ImportDescr> getImportDescrs() {
                return new HashSet<ImportDescr>() {
                    {
                        add( new ImportDescr( "java.util.List" ) );
                        add( new ImportDescr( "java.util.Set" ) );
                    }
                };
            }
        } );
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.Person",
                                                                     new ArrayList(),
                                                                     new ArrayList() );
        assertNotNull( eng );

        assertEquals( 3,
                      eng.getFactTypes().length );
        List<String> factTypes = Arrays.asList( eng.getFactTypes() );
        assertTrue( factTypes.contains( "List" ) );
        assertTrue( factTypes.contains( "Set" ) );
        assertTrue( factTypes.contains( "Person" ) );

        eng = loader.getSuggestionEngine( "package foo \n import org.drools.Person \n declare GenBean \n   id: int \n name : String \n end \n declare GenBean2 \n list: java.util.List \n gb: GenBean \n end",
                                          new ArrayList(),
                                          new ArrayList() );
        assertEquals( 5,
                      eng.getFactTypes().length );
        factTypes = Arrays.asList( eng.getFactTypes() );
View Full Code Here

    }

    @Test
    public void testSuggestionCompLoaderWithExtraImportProvidersAndFilters() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        loader.addExternalImportDescrProvider( new SuggestionCompletionLoader.ExternalImportDescrProvider() {

            public Set<ImportDescr> getImportDescrs() {
                return new HashSet<ImportDescr>() {
                    {
                        add( new ImportDescr( "java.util.List" ) );
                        add( new ImportDescr( "java.util.Set" ) );
                    }
                };
            }
        } );
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.Person \n declare GenBean \n   id: int \n name : String \n end \n declare GenBean2 \n list: java.util.List \n gb: GenBean \n end",
                                                                     new ArrayList(),
                                                                     new ArrayList() );
        eng.setFactTypeFilter( new FactTypeFilter() {

            public boolean filter(String originalFact) {
View Full Code Here

    }

    @Test
    public void testSuggestionCompLoaderWildCards() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        loader.getSuggestionEngine( "package foo \n import org.drools.*",
                                    Collections.<JarInputStream> emptyList(),
                                    Collections.<DSLTokenizedMappingFile> emptyList() );
        assertEquals( 1,
                      loader.getErrors().size() );
        String err = loader.getErrors().get( 0 );
        assertTrue( err.startsWith( "Unable" ) );
    }
View Full Code Here

        assertTrue( err.startsWith( "Unable" ) );
    }

    @Test
    public void testTestAnyEnum() throws Exception {
        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( "",
                                                                                                      Collections.<JarInputStream> emptyList(),
                                                                                                      dsls );

        assertEquals( 1,
                      suggestionEngine.actionDSLSentences.length );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.server.rules.SuggestionCompletionLoader$FieldInfo

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.