use of org.kie.api.builder.model.KieModuleModel 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.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieBuilderTest method testEmptyProjectXml.
@Test
public void testEmptyProjectXml() throws ClassNotFoundException, InterruptedException, IOException {
String namespace = "org.kie.test";
KieServices ks = KieServices.Factory.get();
KieModuleModel kProj = ks.newKieModuleModel();
ReleaseId releaseId = KieServices.Factory.get().newReleaseId(namespace, "memory", "1.0-SNAPSHOT");
KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
generateKProjectXML(kfs, namespace, kProj);
generatePomXML(kfs, releaseId);
generateMessageClass(kfs, namespace);
generateRule(kfs, namespace);
MemoryFileSystem mfs = ((KieFileSystemImpl) kfs).asMemoryFileSystem();
createAndTestKieContainer(releaseId, createKieBuilder(kfs), null);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieBuilderTest method testOnDisc.
@Test
public void testOnDisc() throws ClassNotFoundException, InterruptedException, IOException {
String namespace = "org.kie.test";
KieModuleModel kProj = createKieProject(namespace);
ReleaseId releaseId = KieServices.Factory.get().newReleaseId(namespace, "memory", "1.0-SNAPSHOT");
KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
generateAll(kfs, namespace, releaseId, kProj);
MemoryFileSystem mfs = ((KieFileSystemImpl) kfs).asMemoryFileSystem();
File file = fileManager.getRootDirectory();
mfs.writeAsFs(file);
createAndTestKieContainer(releaseId, createKieBuilder(kfs), namespace);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieBuilderTest method testKieModuleDependencies.
@Test
public void testKieModuleDependencies() throws ClassNotFoundException, InterruptedException, IOException {
KieServices ks = KieServices.Factory.get();
String namespace1 = "org.kie.test1";
ReleaseId releaseId1 = KieServices.Factory.get().newReleaseId(namespace1, "memory", "1.0-SNAPSHOT");
KieModuleModel kProj1 = createKieProject(namespace1);
KieFileSystem kfs1 = KieServices.Factory.get().newKieFileSystem();
generateAll(kfs1, namespace1, releaseId1, kProj1);
KieBuilder kb1 = createKieBuilder(kfs1);
kb1.buildAll();
if (kb1.getResults().hasMessages(Level.ERROR)) {
fail("Unable to build KieJar\n" + kb1.getResults().toString());
}
KieRepository kr = ks.getRepository();
KieModule kModule1 = kr.getKieModule(releaseId1);
assertNotNull(kModule1);
String namespace2 = "org.kie.test2";
ReleaseId releaseId2 = KieServices.Factory.get().newReleaseId(namespace2, "memory", "1.0-SNAPSHOT");
KieModuleModel kProj2 = createKieProject(namespace2);
KieBaseModelImpl kieBase2 = (KieBaseModelImpl) kProj2.getKieBaseModels().get(namespace2);
kieBase2.addInclude(namespace1);
KieFileSystem kfs2 = KieServices.Factory.get().newKieFileSystem();
generateAll(kfs2, namespace2, releaseId2, kProj2);
KieBuilder kb2 = createKieBuilder(kfs2);
kb2.setDependencies(kModule1);
kb2.buildAll();
if (kb2.getResults().hasMessages(Level.ERROR)) {
fail("Unable to build KieJar\n" + kb2.getResults().toString());
}
KieModule kModule2 = kr.getKieModule(releaseId2);
assertNotNull(kModule2);
KieContainer kContainer = ks.newKieContainer(releaseId2);
KieBase kBase = kContainer.getKieBase(namespace2);
KieSession kSession = kBase.newKieSession();
List list = new ArrayList();
kSession.setGlobal("list", list);
kSession.fireAllRules();
assertEquals(2, list.size());
if ("org.kie.test1.Message".equals(list.get(0).getClass().getName())) {
assertEquals("org.kie.test2.Message", list.get(1).getClass().getName());
} else {
assertEquals("org.kie.test2.Message", list.get(0).getClass().getName());
assertEquals("org.kie.test1.Message", list.get(1).getClass().getName());
}
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieBuilderTest method createKieProject.
public KieModuleModel createKieProject(String namespace) {
KieServices ks = KieServices.Factory.get();
KieModuleModel kProj = ks.newKieModuleModel();
KieBaseModel kBase1 = kProj.newKieBaseModel(namespace).setEqualsBehavior(EqualityBehaviorOption.EQUALITY).setEventProcessingMode(EventProcessingOption.STREAM);
return kProj;
}
Aggregations