use of org.kie.api.builder.Message in project drools by kiegroup.
the class WindowTest method initialization.
@Before
public void initialization() {
KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
kfs.write("src/main/resources/kbase1/window_test.drl", drl);
KieBuilder kbuilder = KieServices.Factory.get().newKieBuilder(kfs);
kbuilder.buildAll();
List<Message> res = kbuilder.getResults().getMessages(Level.ERROR);
assertEquals(res.toString(), 0, res.size());
KieBaseConfiguration kbconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbconf.setOption(EventProcessingOption.STREAM);
KieBase kbase = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()).newKieBase(kbconf);
KieSessionConfiguration ksconfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ksconfig.setOption(ClockTypeOption.get("pseudo"));
ksession = kbase.newKieSession(ksconfig, null);
clock = ksession.getSessionClock();
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class BasicUpdateTest method setUp.
@Before
public void setUp() {
final KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
kfs.write(KieServices.Factory.get().getResources().newClassPathResource(UPDATE_TEST_DRL, DeleteTest.class));
final KieBuilder kbuilder = KieServices.Factory.get().newKieBuilder(kfs);
kbuilder.buildAll();
final List<Message> res = kbuilder.getResults().getMessages(Message.Level.ERROR);
assertEquals(res.toString(), 0, res.size());
final KieBase kbase = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()).getKieBase();
ksession = kbase.newKieSession();
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class DslExpansionTest method testDSLExpansion_MessageImplNPE.
@Test
public void testDSLExpansion_MessageImplNPE() throws Exception {
final KieServices ks = KieServices.Factory.get();
final ReleaseId releaseId = ks.newReleaseId("org.kie", "dsl-test", "1.0-SNAPSHOT");
final KieModuleModel kproj = ks.newKieModuleModel();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML(kproj.toXML()).writePomXML(generatePomXml(releaseId)).write("src/main/resources/KBase1/test-dsl.dsl", createDSL()).write("src/main/resources/KBase1/test-rule.dslr", createDRL());
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
if (!messages.isEmpty()) {
for (final Message m : messages) {
System.out.println(m.getText());
}
}
assertTrue(messages.isEmpty());
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class ResultsImpl method toString.
public String toString() {
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("Error Messages:\n");
for (Message msg : filterMessages(Level.ERROR)) {
sBuilder.append(msg.toString());
sBuilder.append("\n");
}
sBuilder.append("---\n");
sBuilder.append("Warning Messages:\n");
for (Message msg : filterMessages(Level.WARNING)) {
sBuilder.append(msg.toString());
sBuilder.append("\n");
}
sBuilder.append("---\n");
sBuilder.append("Info Messages:\n");
for (Message msg : filterMessages(Level.INFO)) {
sBuilder.append(msg.toString());
sBuilder.append("\n");
}
return sBuilder.toString();
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class CalendarTest method test.
@Test
public void test() {
// BZ-1007385
String drl = "package org.drools.compiler.integrationtests;\n" + "\n" + "global java.util.List list\n" + " \n" + "rule \"weekend\"\n" + " calendars \"weekend\"\n" + " \n" + " when\n" + " then\n" + " list.add(\"weekend\");\n" + "end\n" + " \n" + "rule \"weekday\"\n" + " calendars \"weekday\"\n" + "\n" + " when\n" + " then\n" + " list.add(\"weekday\");\n" + "end";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/kbase1/calendars.drl", drl);
KieBuilder kbuilder = ks.newKieBuilder(kfs);
kbuilder.buildAll();
List<Message> res = kbuilder.getResults().getMessages(Level.ERROR);
assertEquals(res.toString(), 0, res.size());
KieBase kbase = ks.newKieContainer(kbuilder.getKieModule().getReleaseId()).getKieBase();
KieSession ksession = ks.newKieContainer(kbuilder.getKieModule().getReleaseId()).newKieSession();
ArrayList<String> list = new ArrayList<String>();
ksession.getCalendars().set("weekend", WEEKEND);
ksession.getCalendars().set("weekday", WEEKDAY);
ksession.setGlobal("list", list);
ksession.fireAllRules();
ksession.dispose();
assertEquals(1, list.size());
}
Aggregations