use of org.drools.modelcompiler.builder.generator.DRLIdGenerator in project drools by kiegroup.
the class DrlxCompilerTest method testCompileUnit.
@Test
@Ignore("Rule Unit compiler is not available in Drools 8 yet")
public void testCompileUnit() throws IOException {
InputStream p = getClass().getClassLoader().getResourceAsStream("drlx1/Example.drlx");
InputStreamResource r = new InputStreamResource(p);
DrlxCompiler drlxCompiler = new DrlxCompiler();
PackageDescr packageDescr = drlxCompiler.toPackageDescr(r);
assertTrue("Should not have compiler errors", drlxCompiler.getResults().isEmpty());
KnowledgeBuilderImpl kbuilder = new KnowledgeBuilderImpl();
PackageRegistry registry = kbuilder.getOrCreatePackageRegistry(packageDescr);
kbuilder.getAndRegisterTypeDeclaration(org.drools.modelcompiler.drlx.Example.class, "org.drools.modelcompiler.drlx");
InternalKnowledgePackage knowledgePackage = registry.getPackage();
PackageModel packageModel = new PackageModel("com.example:dummy:1.0.0", packageDescr.getName(), new KnowledgeBuilderConfigurationImpl(), new DialectCompiletimeRegistry(), new DRLIdGenerator());
ModelGenerator.generateModel(kbuilder, knowledgePackage, packageDescr, packageModel);
assertEquals(1, packageModel.getRuleUnits().size());
}
Aggregations