use of org.drools.core.addon.ClassTypeResolver in project drools by kiegroup.
the class ExpressionTyperTest method setUp.
@Before
public void setUp() throws Exception {
imports = new HashSet<>();
packageModel = new PackageModel("", "", null, null, new DRLIdGenerator());
typeResolver = new ClassTypeResolver(imports, getClass().getClassLoader());
ruleContext = new RuleContext(knowledgeBuilder, packageModel, typeResolver, ruleDescr);
imports.add("org.drools.modelcompiler.domain.Person");
}
use of org.drools.core.addon.ClassTypeResolver in project drools by kiegroup.
the class ConstraintParserTest method setup.
@Before
public void setup() {
PackageModel packageModel = new PackageModel("org.kie.test:constraint-parser-test:1.0.0", "org.kie.test", null, null, null);
Set<String> imports = new HashSet<>();
imports.add("org.drools.modelcompiler.domain.Person");
TypeResolver typeResolver = new ClassTypeResolver(imports, getClass().getClassLoader());
RuleContext context = new RuleContext(null, packageModel, typeResolver, null, 0);
parser = ConstraintParser.defaultConstraintParser(context, packageModel);
}
use of org.drools.core.addon.ClassTypeResolver in project drools by kiegroup.
the class GeneratorHelper method getTypeResolver.
static TypeResolver getTypeResolver(final InvokerStub stub, final ReteEvaluator reteEvaluator, final ClassLoader classLoader) {
InternalKnowledgePackage pkg = reteEvaluator.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;
}
use of org.drools.core.addon.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.drools.core.addon.ClassTypeResolver in project drools by kiegroup.
the class ClassTypeResolverTest method testResolveObjectNotFromImport.
@Test
public void testResolveObjectNotFromImport() 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"));
}
Aggregations