use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class QueryBadResultTest method testQueriesWithSameNameInTwoFiles.
@Test
public void testQueriesWithSameNameInTwoFiles() {
final KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "query-same-name-1.drl", "query-same-name-2.drl");
Assertions.assertThat(kieBuilder.getResults().getMessages(Level.ERROR).isEmpty()).isFalse();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class QueryBadResultTest method testBadAccessToParameterWithoutType.
@Test
public void testBadAccessToParameterWithoutType() {
final KieBuilder kieBuilder = KieUtil.getKieBuilderFromClasspathResources(kieBaseTestConfiguration, getClass(), false, "query-bad-parametr-access.drl");
Assertions.assertThat(kieBuilder.getResults().getMessages(Level.ERROR).isEmpty()).isFalse();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class BuildtimeUtil method createKJarFromResources.
public static ReleaseId createKJarFromResources(final boolean useCanonicalModel, final Resource... resources) throws IOException {
final KieServices kieServices = KieServices.get();
final KieBuilder kieBuilder = getKieBuilderFromResources(kieServices.newKieFileSystem(), useCanonicalModel, resources);
generateKJarFromKieBuilder(kieBuilder, useCanonicalModel);
return kieBuilder.getKieModule().getReleaseId();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class DefaultKieSessionFromFSExampleTest method go.
public void go(PrintStream out) {
String currentFolder = null;
try {
currentFolder = new File(".").getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
File rootFolder = null;
if (currentFolder.endsWith("drools")) {
rootFolder = new File("drools-examples-api/default-kiesession");
} else if (currentFolder.endsWith("drools-examples-api")) {
rootFolder = new File("default-kiesession");
} else {
rootFolder = new File(".");
}
KieServices ks = KieServices.Factory.get();
KieBuilder kieBuilder = ks.newKieBuilder(rootFolder).buildAll();
KieSession kSession = ks.newKieContainer(kieBuilder.getKieModule().getReleaseId()).newKieSession();
kSession.setGlobal("out", out);
kSession.insert(new Message("Dave", "Hello, HAL. Do you read me, HAL?"));
kSession.fireAllRules();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class KieModuleModelExample method go.
public void go(PrintStream out) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
Resource ex1Res = ks.getResources().newFileSystemResource(getFile("named-kiesession"));
Resource ex2Res = ks.getResources().newFileSystemResource(getFile("kiebase-inclusion"));
ReleaseId rid = ks.newReleaseId("org.drools", "kiemodulemodel-example", Drools.getFullVersion());
kfs.generateAndWritePomXML(rid);
KieModuleModel kModuleModel = ks.newKieModuleModel();
kModuleModel.newKieBaseModel("kiemodulemodel").addInclude("kbase1").addInclude("kbase2").newKieSessionModel("ksession6");
kfs.writeKModuleXML(kModuleModel.toXML());
kfs.write("src/main/resources/kiemodulemodel/HAL6.drl", getRule());
KieBuilder kb = ks.newKieBuilder(kfs);
kb.setDependencies(ex1Res, ex2Res);
// kieModule is automatically deployed to KieRepository if successfully built.
kb.buildAll();
if (kb.getResults().hasMessages(Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = ks.newKieContainer(rid);
KieSession kSession = kContainer.newKieSession("ksession6");
kSession.setGlobal("out", out);
Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?");
kSession.insert(msg1);
kSession.fireAllRules();
Object msg2 = createMessage(kContainer, "Dave", "Open the pod bay doors, HAL.");
kSession.insert(msg2);
kSession.fireAllRules();
Object msg3 = createMessage(kContainer, "Dave", "What's the problem?");
kSession.insert(msg3);
kSession.fireAllRules();
}
Aggregations