use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieRepositoryScannerImpl method updateKieModule.
private boolean updateKieModule(DependencyDescriptor oldDependency, Artifact artifact) {
org.appformer.maven.support.AFReleaseId newReleaseId = new DependencyDescriptor(artifact).getReleaseId();
InternalKieModule kieModule = createKieModule(newReleaseId, artifact.getFile());
if (kieModule != null) {
addDependencies(kieModule, artifactResolver, artifactResolver.getArtifactDependecies(newReleaseId.toString()));
ResultsImpl messages = kieModule.build();
if (messages.filterMessages(Message.Level.ERROR).isEmpty()) {
Results updateMessages = kieContainer.updateDependencyToVersion(adapt(oldDependency.getArtifactReleaseId()), adapt(newReleaseId));
oldDependency.setArtifactVersion(artifact.getVersion());
// append all update Results into build Results to notify listeners
messages.getMessages().addAll(updateMessages.getMessages());
}
listeners.fireKieScannerUpdateResultsEventImpl(messages);
return !messages.hasMessages(Message.Level.ERROR);
}
return false;
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieBuilderTest method checkKModule.
private void checkKModule(final String kmodule, final int expectedErrors) {
final KieServices ks = KieServices.Factory.get();
final ReleaseId releaseId = ks.newReleaseId("org.kie", "test-kie-builder", "1.0.0");
final KieFileSystem kfs = ks.newKieFileSystem().generateAndWritePomXML(releaseId).writeKModuleXML(kmodule);
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
kieBuilder.buildAll();
final Results results = kieBuilder.getResults();
assertEquals(expectedErrors, results.getMessages(org.kie.api.builder.Message.Level.ERROR).size());
assertNotNull(((InternalKieBuilder) kieBuilder).getKieModuleIgnoringErrors());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieBuilderTest method testReportKBuilderErrorWhenUsingAJavaClassWithNoPkg.
@Test
public void testReportKBuilderErrorWhenUsingAJavaClassWithNoPkg() {
// BZ-995018
final String java = "public class JavaClass { }\n";
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem().write("src/main/java/JavaClass.java", java);
final Results results = ks.newKieBuilder(kfs).buildAll().getResults();
System.out.println(results.getMessages());
assertEquals(1, results.getMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class AccumulateTest method testAccumulateWithoutSeparator.
@Test
public void testAccumulateWithoutSeparator() throws Exception {
// DROOLS-602
String str = "package org.drools.compiler\n" + "\n" + "rule \"Constraints everywhere\" \n" + " when\n" + " $person : Person( $likes : likes )\n" + " accumulate( Cheese( type == $likes, $price : price )\n" + " $sum : sum( $price ),\n" + " $avg : average( $price ),\n" + " $min : min( $price );\n" + " $min == 3,\n" + " $sum > 10 )\n" + " then\n" + " // do something\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 AccumulateTest method testIncompatibleListOnAccumulateFunction.
@Test
public void testIncompatibleListOnAccumulateFunction() {
// DROOLS-1243
String drl = "import " + MyPerson.class.getCanonicalName() + ";\n" + "import " + BigDecimal.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + "rule R when\n" + " $theFrom : String() from accumulate(MyPerson( $val : age ); \n" + " collectList( $val ) )\n" + "then\n" + " list.add($theFrom);\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();
assertFalse(results.getMessages().isEmpty());
}
Aggregations