use of org.kie.api.builder.Message in project drools by kiegroup.
the class DeleteTest method setUp.
@Before
public void setUp() {
KieFileSystem kfs = KieServices.Factory.get().newKieFileSystem();
kfs.write(KieServices.Factory.get().getResources().newClassPathResource(DELETE_TEST_DRL, DeleteTest.class));
KieBuilder kbuilder = KieServices.Factory.get().newKieBuilder(kfs);
kbuilder.buildAll();
List<Message> res = kbuilder.getResults().getMessages(Level.ERROR);
Assertions.assertThat(res).isEmpty();
KieBase kbase = KieServices.Factory.get().newKieContainer(kbuilder.getKieModule().getReleaseId()).getKieBase();
ksession = kbase.newKieSession();
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class KieModuleMetaDataTest method testKieModuleMetaDataInMemoryWithJavaClassDefaultPackage.
@Test
public void testKieModuleMetaDataInMemoryWithJavaClassDefaultPackage() throws Exception {
final KieServices ks = KieServices.Factory.get();
final ReleaseId releaseId = ks.newReleaseId("org.kie", "javaDefaultPackage", "1.0-SNAPSHOT");
final KieModuleModel kproj = ks.newKieModuleModel();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML(kproj.toXML()).writePomXML(generatePomXml(releaseId)).write("src/main/java/test/Bean.java", createJavaSource());
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
assertTrue(messages.isEmpty());
final KieModule kieModule = kieBuilder.getKieModule();
final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule);
// The call to kieModuleMetaData.getClass() assumes a Java file has an explicit package
final Class<?> beanClass = kieModuleMetaData.getClass("", "test.Bean");
assertNotNull(beanClass);
final TypeMetaInfo beanMetaInfo = kieModuleMetaData.getTypeMetaInfo(beanClass);
assertNotNull(beanMetaInfo);
}
use of org.kie.api.builder.Message in project drools by kiegroup.
the class KieModuleMetaDataTest method testGetRuleNames.
@Test
public void testGetRuleNames() {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/test1.drl", "package org.test\n" + "rule A\n" + " when\n" + "then\n" + "end\n" + "rule B\n" + " when\n" + "then\n" + "end\n");
kfs.write("src/main/resources/test2.drl", "package org.test\n" + "rule C\n" + " when\n" + "then\n" + "end\n");
final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
assertTrue(messages.isEmpty());
final KieModule kieModule = kieBuilder.getKieModule();
final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule);
Collection<String> rules = kieModuleMetaData.getRuleNamesInPackage("org.test");
assertEquals(3, rules.size());
assertTrue(rules.containsAll(asList("A", "B", "C")));
}
Aggregations