use of org.kie.internal.builder.DecisionTableConfiguration in project drools by kiegroup.
the class EmptyHeaderTest method testEmptyConditionInXLS.
@Test(expected = DecisionTableParseException.class)
public void testEmptyConditionInXLS() {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("emptyCondition.xls", getClass()), ResourceType.DTABLE, dtconf);
}
use of org.kie.internal.builder.DecisionTableConfiguration in project drools by kiegroup.
the class EmptyHeaderTest method testEmptyActionInCSV.
@Test(expected = DecisionTableParseException.class)
public void testEmptyActionInCSV() {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.CSV);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("emptyAction.csv", getClass()), ResourceType.DTABLE, dtconf);
}
use of org.kie.internal.builder.DecisionTableConfiguration in project drools by kiegroup.
the class FixedPatternTest method testFixedPattern.
@Test
public void testFixedPattern() throws FileNotFoundException {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("fixedPattern.xls", getClass()), ResourceType.DTABLE, dtconf);
if (kbuilder.hasErrors()) {
fail(kbuilder.getErrors().toString());
}
InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addPackages(kbuilder.getKnowledgePackages());
KieSession ksession = kbase.newKieSession();
List<Long> list = new ArrayList<Long>();
ksession.setGlobal("list", list);
ksession.insert(1L);
ksession.insert(2);
ksession.fireAllRules();
assertEquals(1, list.size());
assertEquals(1L, (long) list.get(0));
ksession.dispose();
}
use of org.kie.internal.builder.DecisionTableConfiguration in project drools by kiegroup.
the class SpreadsheetCompilerUnitTest method readKnowledgeBase.
private KieBase readKnowledgeBase(String resource) throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration config = KnowledgeBuilderFactory.newDecisionTableConfiguration();
config.setInputType(DecisionTableInputType.XLS);
kbuilder.add(ResourceFactory.newClassPathResource(resource, getClass()), ResourceType.DTABLE, config);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addPackages(kbuilder.getKnowledgePackages());
return kbase;
}
use of org.kie.internal.builder.DecisionTableConfiguration in project drools by kiegroup.
the class SpreadsheetIntegrationExampleTest method testNamedWorksheet.
@Test
public void testNamedWorksheet() throws Exception {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
dtconf.setWorksheetName("Tables_2");
Resource dt = ResourceFactory.newClassPathResource("/data/IntegrationExampleTest.xls", getClass()).setConfiguration(dtconf);
KieSession ksession = getKieSession(dt);
// ASSERT AND FIRE
ksession.insert(new Cheese("cheddar", 42));
ksession.insert(new Person("michael", "stilton", 25));
final List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
ksession.fireAllRules();
assertEquals(1, list.size());
assertEquals("Young man cheddar", list.get(0));
}
Aggregations