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

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


        assertEquals("SomeFact", facts[1]);
    }

    @Test
    public void testTypeDeclarations() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();

        String header ="";
        header += "package foo\n";

        header += "declare Applicant\n";
  header += "     creditRating: String\n";
  header += "     approved: Boolean\n";
  header += "     applicationDate: java.util.Date\n";
  header += "     age: Integer\n";
  header += "     name: String\n";
        header += "end\n";

        header += "declare LoanApplication\n";
  header += "     amount: Integer\n";
  header += "     approved: Boolean\n";
  header += "     deposit: Integer\n";
  header += "     approvedRate: Integer\n";
  header += "     lengthYears: Integer\n";
  header += "     explanation: String\n";
  header += "     insuranceCost: Integer\n";
  header += "     applicant: Applicant\n";
        header += "end\n";

        SuggestionCompletionEngine eng = loader.getSuggestionEngine( header, new ArrayList(), new ArrayList() );
        assertNotNull(eng);

        assertEquals(SuggestionCompletionEngine.TYPE_STRING, eng.getFieldType( "Applicant", "creditRating" ));
        assertEquals("java.lang.String", eng.getFieldClassName( "Applicant", "creditRating" ));
        assertEquals(FIELD_CLASS_TYPE.TYPE_DECLARATION_CLASS, eng.getFieldClassType( "Applicant", "creditRating" ));
View Full Code Here


    }

    @Test
    public void testLoaderWithExistingClassloader() throws Exception {
        MockClassLoader mcl = new MockClassLoader();
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader(mcl);
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.foo.Bar", new ArrayList(), new ArrayList() );
        assertNotNull(eng);
        //assertNotNull(eng.dataEnumLists);
        assertTrue(mcl.called);
    }
View Full Code Here

import org.drools.lang.descr.ImportDescr;

public class SuggestionCompletionLoaderTest extends TestCase {

    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

        assertNotNull(eng);

    }

    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());
        assertTrue(factTypes.contains("List"));
        assertTrue(factTypes.contains("Set"));
        assertTrue(factTypes.contains("Person"));
View Full Code Here

        assertTrue(factTypes.contains("GenBean2"));

    }

    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) {
                return originalFact.equals("List") || originalFact.equals("GenBean2");
            }
View Full Code Here

        assertTrue(factTypes.contains("GenBean"));

    }

    public void testSuggestionCompLoaderWildcards() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        loader.getSuggestionEngine( "package foo \n import org.drools.*", new ArrayList(), new ArrayList() );
        assertEquals(1, loader.getErrors().size());
        String err = loader.getErrors().get(0);
        assertTrue(err.startsWith("Unable"));
    }
View Full Code Here

        String err = loader.getErrors().get(0);
        assertTrue(err.startsWith("Unable"));
    }

    public void testLoadDifferentFieldTypes() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.ide.common.server.rules.SomeFact", new ArrayList(), new ArrayList() );
        assertNotNull(eng);

        assertEquals(SuggestionCompletionEngine.TYPE_NUMERIC, eng.getFieldType( "SomeFact", "age" ));
        assertEquals(SuggestionCompletionEngine.TYPE_STRING, eng.getFieldType( "SomeFact", "likes"));
        assertEquals(SuggestionCompletionEngine.TYPE_STRING, eng.getFieldType( "SomeFact","name"));
View Full Code Here

        assertEquals(SuggestionCompletionEngine.TYPE_COLLECTION,eng.getFieldType( "SomeFact", "factListString"));
        assertEquals("String",eng.getParametricFieldType("SomeFact", "factListString"));
    }

    public void testLoadDifferentMethodTypes() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n import org.drools.ide.common.server.rules.SomeFact", new ArrayList(), new ArrayList() );
        assertNotNull(eng);

        assertEquals(List.class.getName(), eng.getMethodClassType("SomeFact", "aMethod(int)"));
        assertEquals("SomeFact", eng.getParametricFieldType("SomeFact", "aMethod(int)"));
    }
View Full Code Here

        assertEquals(List.class.getName(), eng.getMethodClassType("SomeFact", "aMethod(int)"));
        assertEquals("SomeFact", eng.getParametricFieldType("SomeFact", "aMethod(int)"));
    }

    public void testGeneratedBeans() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \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() );
        assertFalse(loader.hasErrors());
        assertNotNull(eng);

        assertEquals(2, eng.getFactTypes().length);
        assertEquals("GenBean", eng.getFactTypes()[0]);
        assertEquals("GenBean2", eng.getFactTypes()[1]);
View Full Code Here

        assertEquals("GenBean", eng.getFieldType("GenBean2", "gb"));
    }

    public void testGlobal() throws Exception {
        SuggestionCompletionLoader loader = new SuggestionCompletionLoader();
        SuggestionCompletionEngine eng = loader.getSuggestionEngine( "package foo \n global org.drools.Person p", new ArrayList(), new ArrayList() );
        assertNotNull(eng);
        assertFalse(loader.hasErrors());

        assertEquals(1, eng.getGlobalVariables().length);
        assertEquals("p", eng.getGlobalVariables()[0]);
        assertEquals("Person", eng.getGlobalVariable("p"));
        String[] flds = (String[]) eng.getModelFields("Person");
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.