use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class FactPopulatorTest method getTypeResolver.
private TypeResolver getTypeResolver() {
TypeResolver resolver = new ClassTypeResolver(new HashSet<String>(), getClassLoader());
resolver.addImport("org.drools.workbench.models.testscenarios.backend.MyCollectionWrapper");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheesery");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheese");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.SqlDateWrapper");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.CheeseType");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.Person");
resolver.addImport("org.drools.workbench.models.testscenarios.backend.OuterFact");
return resolver;
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class GlobalFactPopulatorTest method testWithGlobals.
@Test
public void testWithGlobals() throws Exception {
FactData global = new FactData("Cheese", "c", Arrays.<Field>asList(new FieldData("type", "cheddar")), false);
TypeResolver resolver = new ClassTypeResolver(new HashSet<String>(), Thread.currentThread().getContextClassLoader());
resolver.addImport("org.drools.workbench.models.testscenarios.backend.Cheese");
KieSession ksession = mock(KieSession.class);
Map<String, Object> populatedData = new HashMap<String, Object>();
Map<String, Object> globalData = new HashMap<String, Object>();
GlobalFactPopulator globalFactPopulator = new GlobalFactPopulator(populatedData, resolver, global, globalData);
globalFactPopulator.populate(ksession, new HashMap<String, FactHandle>());
verify(ksession).setGlobal(eq(global.getName()), any(Object.class));
assertEquals(1, globalData.size());
assertEquals(0, populatedData.size());
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class NewFactPopulatorTest method setUp.
@Before
public void setUp() throws Exception {
typeResolver = new ClassTypeResolver(new HashSet<String>(), Thread.currentThread().getContextClassLoader());
populatedData = new HashMap<String, Object>();
workingMemory = mock(KieSession.class);
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class ToTypedExpressionTest method setUp.
@Before
public void setUp() throws Exception {
imports = new HashSet<>();
packageModel = new PackageModel("", null, false, null);
typeResolver = new ClassTypeResolver(imports, getClass().getClassLoader());
ruleContext = new RuleContext(knowledgeBuilder, packageModel, ruleDescr, typeResolver, true);
imports.add("org.drools.modelcompiler.domain.Person");
}
use of org.kie.soup.project.datamodel.commons.types.ClassTypeResolver in project drools by kiegroup.
the class PackageHeaderLoader method findImportsFromJars.
private void findImportsFromJars(Collection<String> imports, List<JarInputStream> jarInputStreams) throws IOException {
ClassTypeResolver resolver = new ClassTypeResolver(new HashSet<String>(), new VerifierMapBackedClassLoader(jarInputStreams));
for (String className : imports) {
classNames.add(className);
try {
Class clazz = resolver.resolveType(className);
addFields(clazz);
} catch (ClassNotFoundException e) {
missingClasses.add(className);
}
}
}
Aggregations