Search in sources :

Example 1 with Message

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();
}
Also used : KieBaseConfiguration(org.kie.api.KieBaseConfiguration) KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieBase(org.kie.api.KieBase) KieBuilder(org.kie.api.builder.KieBuilder) KieSessionConfiguration(org.kie.api.runtime.KieSessionConfiguration) Before(org.junit.Before)

Example 2 with Message

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();
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieBase(org.kie.api.KieBase) KieBuilder(org.kie.api.builder.KieBuilder) Before(org.junit.Before)

Example 3 with Message

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieModuleModel(org.kie.api.builder.model.KieModuleModel) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Example 4 with Message

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();
}
Also used : Message(org.kie.api.builder.Message)

Example 5 with Message

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieBase(org.kie.api.KieBase) ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) KieSession(org.kie.api.runtime.KieSession) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Aggregations

Message (org.kie.api.builder.Message)33 KieBuilder (org.kie.api.builder.KieBuilder)30 KieFileSystem (org.kie.api.builder.KieFileSystem)26 Test (org.junit.Test)21 KieServices (org.kie.api.KieServices)19 InternalKieBuilder (org.kie.internal.builder.InternalKieBuilder)10 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)7 KieBase (org.kie.api.KieBase)6 ReleaseId (org.kie.api.builder.ReleaseId)5 KieModule (org.kie.api.builder.KieModule)4 KieModuleModel (org.kie.api.builder.model.KieModuleModel)4 IncrementalResults (org.kie.internal.builder.IncrementalResults)4 Before (org.junit.Before)3 Resource (org.kie.api.io.Resource)3 KieSession (org.kie.api.runtime.KieSession)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 MavenRepository (org.appformer.maven.integration.MavenRepository)1 MavenRepository.getMavenRepository (org.appformer.maven.integration.MavenRepository.getMavenRepository)1