Search in sources :

Example 76 with Results

use of org.kie.api.builder.Results in project drools by kiegroup.

the class PMMLUsageDemoTest method invokePmmlWithTraitMissing.

@Test
public void invokePmmlWithTraitMissing() {
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    kfs.write(ResourceFactory.newClassPathResource(pmmlSource).setResourceType(ResourceType.PMML));
    Results res = ks.newKieBuilder(kfs).buildAll().getResults();
    if (res.hasMessages(Message.Level.ERROR)) {
        System.out.println(res.getMessages(Message.Level.ERROR));
    }
    assertEquals(0, res.getMessages(Message.Level.ERROR).size());
    KieSession kSession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
    kSession.insert("trigger");
    kSession.fireAllRules();
    System.out.println(reportWMObjects(kSession));
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Results(org.kie.api.builder.Results) QueryResults(org.kie.api.runtime.rule.QueryResults) KieServices(org.kie.api.KieServices) KieSession(org.kie.api.runtime.KieSession) Test(org.junit.Test)

Example 77 with Results

use of org.kie.api.builder.Results in project drools by kiegroup.

the class KModuleWithDecisionTablesTest method testNonEmptyKieBaseWithWrongCSV.

@Test
public void testNonEmptyKieBaseWithWrongCSV() throws Exception {
    String csv = "\"RuleSet\",\"org.jboss.qa.brms.bre.functional.expert.decisiontable\",,,\n" + "\"Import\",\"org.jboss.qa.brms.domain.Message\",,,\n" + ",,,,\n" + "\"RuleTable TimerCalendarRule\",,,,\n" + "\"NAME\",\"TIMER\",\"CALENDARS\",\"ACTION\",\"Description\"\n" + ",,,,\n" + ",,,\"insert(new Message(\\\"$param\\\"));\",\n" + "\"Rule name\",\"Timer value\",\"Calendar value\",\"Inserted message text\",\"Note\"\n" + "\"Weekend rule\",,\"weekend\",\"Weekend rule\",\n" + "\"Every 100 ms weekday rule\",\"int: 0 100ms\",\"weekday\",\"Every 100 ms weekday rule\",\n" + "\"Delayed Tuesday rule\",\"int: 1000 0\",\"tuesday\",\"Delayed Tuesday rule\",\n" + "\"Delayed repetitive Friday rule\",\"int: 500ms 1s\",\"friday\",\"Delayed repetitive Friday rule\",\n" + "\"Delayed rule\",\"int: 1s 0ms\",,\"Delayed rule\",\n" + "\"Repetitive rule\",\"int: 0ms 100\",,\"Repetitive rule\",\n" + "\"Repetitive delayed rule\",\"int: 1s 100ms\",,\"Repetitive delayed rule\",\n" + "\"Cron rule\",\"cron: */1 * * * * ?\",,\"Cron rule\",\n";
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.csv", csv);
    Results results = ks.newKieBuilder(kfs).buildAll().getResults();
    assertFalse(results.getMessages().isEmpty());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Results(org.kie.api.builder.Results) KieServices(org.kie.api.KieServices) Test(org.junit.Test)

Example 78 with Results

use of org.kie.api.builder.Results in project drools by kiegroup.

the class CompilationFailuresTest method testNonQuotedStringComapre.

@Test
public void testNonQuotedStringComapre() {
    String drl = "declare Fact\n" + "    field : String\n" + "end\n" + "rule R when\n" + "    Fact( field == someString )\n" + "then\n" + "end\n";
    Results results = getCompilationResults(drl);
    assertFalse(results.getMessages(Message.Level.ERROR).isEmpty());
}
Also used : Results(org.kie.api.builder.Results) Test(org.junit.Test)

Example 79 with Results

use of org.kie.api.builder.Results in project drools by kiegroup.

the class CompilationFailuresTest method testBadQueryArg.

@Test
public void testBadQueryArg() {
    String drl = "import " + Person.class.getCanonicalName() + "\n" + "query queryWithParamWithoutType( tname , tage)\n" + "    person : Person(name == tname, age < tage )\n" + "end\n";
    Results results = getCompilationResults(drl);
    assertFalse(results.getMessages(Message.Level.ERROR).isEmpty());
}
Also used : Results(org.kie.api.builder.Results) Person(org.drools.modelcompiler.domain.Person) Test(org.junit.Test)

Example 80 with Results

use of org.kie.api.builder.Results in project drools by kiegroup.

the class OOPathTest method testInvalid.

private void testInvalid(final String drl) {
    final KieServices ks = KieServices.Factory.get();
    final KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
    final Results results = ks.newKieBuilder(kfs).buildAll().getResults();
    assertTrue(results.hasMessages(Message.Level.ERROR));
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Results(org.kie.api.builder.Results) KieServices(org.kie.api.KieServices)

Aggregations

Results (org.kie.api.builder.Results)92 Test (org.junit.Test)81 KieServices (org.kie.api.KieServices)72 KieFileSystem (org.kie.api.builder.KieFileSystem)60 KieContainer (org.kie.api.runtime.KieContainer)36 KieBuilder (org.kie.api.builder.KieBuilder)32 KieSession (org.kie.api.runtime.KieSession)25 IncrementalResults (org.kie.internal.builder.IncrementalResults)20 ReleaseId (org.kie.api.builder.ReleaseId)19 QueryResults (org.kie.api.runtime.rule.QueryResults)17 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)15 KieBase (org.kie.api.KieBase)14 InternalKieBuilder (org.kie.internal.builder.InternalKieBuilder)13 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)11 KieHelper (org.kie.internal.utils.KieHelper)11 KieModuleModel (org.kie.api.builder.model.KieModuleModel)10 FactType (org.kie.api.definition.type.FactType)10 ArrayList (java.util.ArrayList)9 FlatQueryResults (org.drools.core.runtime.rule.impl.FlatQueryResults)9 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)7