use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class ClassTypeResolverTest method testResolveFullTypeName.
@Test
public void testResolveFullTypeName() throws Exception {
final TypeResolver resolver = new ClassTypeResolver(new HashSet(), Thread.currentThread().getContextClassLoader());
resolver.addImport("org.drools.core.test.model.Cheese");
resolver.addImport("org.drools.core.test.model.FirstClass");
assertEquals("org.drools.core.test.model.Cheese", resolver.getFullTypeName("Cheese"));
assertEquals("org.drools.core.test.model.FirstClass", resolver.getFullTypeName("FirstClass"));
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class ClassTypeResolverTest method testResolveArrayOfObjectsNotFromImport.
@Test
public void testResolveArrayOfObjectsNotFromImport() throws Exception {
final ClassTypeResolver resolver = new ClassTypeResolver(new HashSet(), Thread.currentThread().getContextClassLoader());
assertEquals(String[].class, resolver.resolveType("String[]"));
assertEquals(String[].class, resolver.resolveType("java.lang.String[]"));
try {
assertEquals(Cheese[].class, resolver.resolveType("Cheese[]"));
fail("Should raise a ClassNotFoundException");
} catch (final ClassNotFoundException e) {
// success
}
assertEquals(Cheese[].class, resolver.resolveType("org.drools.core.test.model.Cheese[]"));
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class GeneratorHelper method getTypeResolver.
static TypeResolver getTypeResolver(final InvokerStub stub, final WorkingMemory workingMemory, final ClassLoader classLoader) {
InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage(stub.getPackageName());
TypeResolver typeResolver = pkg == null ? null : pkg.getTypeResolver();
if (typeResolver == null) {
Set<String> imports = new HashSet<String>();
for (String imp : stub.getPackageImports()) {
imports.add(imp);
}
typeResolver = new ClassTypeResolver(imports, classLoader, stub.getPackageName());
}
return typeResolver;
}
Aggregations