use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class KieModuleDeploymentHelperImpl method createKieJarAndDeployToMaven.
@Override
public void createKieJarAndDeployToMaven(String groupId, String artifactId, String version, String kbaseName, String ksessionName, List<String> resourceFilePaths) {
ReleaseId releaseId = new ReleaseIdImpl(groupId, artifactId, version);
internalCreateAndDeployKjarToMaven(releaseId, kbaseName, ksessionName, resourceFilePaths, null, null);
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class AccumulateTest method testImportAccumulateFunctionWithDeclaration.
@Test
public void testImportAccumulateFunctionWithDeclaration() throws Exception {
// DROOLS-750
String drl = "package org.foo.bar\n" + "import accumulate " + TestFunction.class.getCanonicalName() + " f;\n" + "import " + Person.class.getCanonicalName() + ";\n" + "declare Person \n" + " @propertyReactive\n" + "end\n" + "rule X when\n" + " accumulate( $s : String(),\n" + " $v : f( $s ) )\n" + "then\n" + "end\n";
ReleaseId releaseId = new ReleaseIdImpl("foo", "bar", "1.0");
KieServices ks = KieServices.Factory.get();
createAndDeployJar(ks, releaseId, drl);
KieContainer kc = ks.newKieContainer(releaseId);
KieSession ksession = kc.newKieSession();
AgendaEventListener ael = mock(AgendaEventListener.class);
ksession.addEventListener(ael);
ksession.insert("x");
ksession.fireAllRules();
ArgumentCaptor<AfterMatchFiredEvent> ac = ArgumentCaptor.forClass(AfterMatchFiredEvent.class);
verify(ael).afterMatchFired(ac.capture());
assertThat((Integer) ac.getValue().getMatch().getDeclarationValue("$v"), is(Integer.valueOf(1)));
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class AccumulateTest method testImportAccumulateFunction.
@Test
public void testImportAccumulateFunction() throws Exception {
String drl = "package org.foo.bar\n" + "import accumulate " + TestFunction.class.getCanonicalName() + " f\n" + "rule X when\n" + " accumulate( $s : String(),\n" + " $v : f( $s ) )\n" + "then\n" + "end\n";
ReleaseId releaseId = new ReleaseIdImpl("foo", "bar", "1.0");
KieServices ks = KieServices.Factory.get();
createAndDeployJar(ks, releaseId, drl);
KieContainer kc = ks.newKieContainer(releaseId);
KieSession ksession = kc.newKieSession();
AgendaEventListener ael = mock(AgendaEventListener.class);
ksession.addEventListener(ael);
ksession.insert("x");
ksession.fireAllRules();
ArgumentCaptor<AfterMatchFiredEvent> ac = ArgumentCaptor.forClass(AfterMatchFiredEvent.class);
verify(ael).afterMatchFired(ac.capture());
assertThat((Integer) ac.getValue().getMatch().getDeclarationValue("$v"), is(Integer.valueOf(1)));
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class KieBuilderTest method testInvalidPomXmlGAV.
@Test
public void testInvalidPomXmlGAV() throws ClassNotFoundException, InterruptedException, IOException {
String namespace = "org.kie.test";
KieModuleModel kProj = createKieProject(namespace);
ReleaseId releaseId = new ReleaseIdImpl("", "", "");
KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
generatePomXML(kfs, releaseId);
generateMessageClass(kfs, namespace);
generateRule(kfs, namespace);
MemoryFileSystem mfs = ((KieFileSystemImpl) kfs).asMemoryFileSystem();
KieBuilder kieBuilder = createKieBuilder(kfs);
kieBuilder.buildAll();
assertTrue(kieBuilder.getResults().hasMessages(Level.ERROR));
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class DroolsAbstractPMMLTest method createExecutor.
protected RuleUnitExecutor createExecutor(String sourceName) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
ReleaseId releaseId = new ReleaseIdImpl("org.kie:pmmlTest:1.0-SNAPSHOT");
((KieRepositoryImpl) kr).setDefaultGAV(releaseId);
Resource res = ResourceFactory.newClassPathResource(sourceName);
kbase = new KieHelper().addResource(res, ResourceType.PMML).build();
assertNotNull(kbase);
RuleUnitExecutor executor = RuleUnitExecutor.create().bind(kbase);
KieContainer kc = ((KnowledgeBaseImpl) ((InternalRuleUnitExecutor) executor).getKieSession().getKieBase()).getKieContainer();
InternalKieModule ikm = (InternalKieModule) kr.getKieModule(releaseId);
try (FileOutputStream fos = new FileOutputStream("/tmp/outputModule.jar")) {
fos.write(ikm.getBytes());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
kc.getKieBaseNames().forEach(n -> {
System.out.println(n);
});
data = executor.newDataSource("request");
resultData = executor.newDataSource("results");
pmmlData = executor.newDataSource("pmmlData");
return executor;
}
Aggregations