}
@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());
assertTrue(factTypes.contains("List"));
assertTrue(factTypes.contains("Set"));
assertTrue(factTypes.contains("Person"));