use of org.kie.api.builder.Results in project drools by kiegroup.
the class AccumulateTest method testFromAccumulateWithoutSeparator.
@Test
public void testFromAccumulateWithoutSeparator() throws Exception {
// DROOLS-602
String str = "rule R when\n" + " $count : Number( ) from accumulate (\n" + " $s: String()\n" + " count($s)\n" + " )\n" + "then\n" + " System.out.println($count);\n" + "end";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", str);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertFalse(results.getMessages().isEmpty());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class LengthSlidingWindowTest method testCompilationFailureWithUnknownWindow.
@Test
public void testCompilationFailureWithUnknownWindow() {
// DROOLS-841
String drl = "import " + StockTick.class.getCanonicalName() + "\n" + "global java.util.List list;\n" + "declare StockTick @role( event ) end\n" + "declare window RhtStocksWindow\n" + " StockTick() over window:length( 3 )\n" + "end\n" + "rule R\n" + "when \n" + " accumulate( StockTick( company == \"RHT\", $price : price ) from window AbcStocksWindow; $total : sum($price) )\n" + "then \n" + " list.add($total);\n" + "end \n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertEquals(1, results.getMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class MessageImplTests method testMessageWithIncrementalBuild.
@Test
public void testMessageWithIncrementalBuild() throws Exception {
// Some suitably duff DSL to generate errors
String dsl1 = "bananna\n";
// Some suitably valid DRL
String drl1 = "import org.drools.compiler.Person;\n" + "rule R1\n" + "when\n" + "There is a Person\n" + "then\n" + "end\n";
// Some suitably valid DRL
String drl2 = "rule R2\n" + "when\n" + "then\n" + "end\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/dsl.dsl", dsl1).write("src/main/resources/drl.dslr", drl1);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results fullBuildResults = kieBuilder.getResults();
assertEquals(3, fullBuildResults.getMessages().size());
kfs.write("src/main/resources/r2.drl", drl2);
IncrementalResults incrementalBuildResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/r2.drl").build();
assertEquals(0, incrementalBuildResults.getAddedMessages().size());
assertEquals(0, incrementalBuildResults.getRemovedMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class DslTest method testGreedyDsl.
@Test
public void testGreedyDsl() {
// BZ-1078839
String dsl = "[when]There is a number with value of {value}=i:Integer(intValue() == {value})\n" + "[when]There is a number with=i:Integer()\n";
String dslr = "package org.test \n" + "rule 'sample rule' \n" + "when \n" + " There is a number with value of 10\n" + "then \n" + "end \n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.dslr", dslr).write("src/main/resources/r1.dsl", dsl);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertEquals(0, results.getMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class EnumTest method testEnumsWithCompositeBuildingProcess.
@Test
public void testEnumsWithCompositeBuildingProcess() throws Exception {
final String drl = "package org.test; " + "" + "declare enum DaysOfWeek " + " SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;\n" + "end\n" + "declare Test " + " field: DaysOfWeek " + "end";
final KieHelper kieHelper = new KieHelper();
kieHelper.addContent(drl, ResourceType.DRL);
final Results res = kieHelper.verify();
assertEquals(0, res.getMessages().size());
}
Aggregations