use of org.kie.api.io.Resource in project drools by kiegroup.
the class DecisionTableTest method testCSVWithDateAttributes.
@Test
public void testCSVWithDateAttributes() {
final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("sample_dates.csv", getClass(), DecisionTableInputType.CSV);
testDecisionTableWithDateAttributes(decisionTable);
}
use of org.kie.api.io.Resource in project drools by kiegroup.
the class DecisionTableTest method testActivationGroup.
@Test
public void testActivationGroup() {
final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("agenda-group.csv", getClass(), DecisionTableInputType.CSV);
final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable);
final KieSession ksession = kbase.newKieSession();
final TrackingAgendaEventListener listener = new TrackingAgendaEventListener();
ksession.addEventListener(listener);
// only one rule from activation group may fire
ksession.insert("activationGroup");
ksession.fireAllRules();
Assertions.assertThat(listener.isRuleFired("c1")).isFalse();
Assertions.assertThat(listener.isRuleFired("c2")).isTrue();
Assertions.assertThat(listener.isRuleFired("c3")).isFalse();
}
use of org.kie.api.io.Resource in project drools by kiegroup.
the class DecisionTableTest method testMultipleTableXLS.
@Test
public void testMultipleTableXLS() {
final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("multiple_tables.xls", getClass(), DecisionTableInputType.XLS);
final KieBase kbase = KieBaseUtil.getKieBaseFromResources(kieBaseTestConfiguration, decisionTable);
Assertions.assertThat(2).isEqualTo(kbase.getKiePackages().size());
final KieSession session = kbase.newKieSession();
// testing person object from the first table
final Person person = new Person("Paul");
person.setId(1);
Assertions.assertThat(person.getName()).isEqualTo("Paul");
Assertions.assertThat(person.getId()).isEqualTo(1);
// testing second person, he should be renamed by rules in the second
// table
final Person person2 = new Person("Helmut von Seireit");
person2.setId(1000);
Assertions.assertThat(person2.getName()).isEqualTo("Helmut von Seireit");
Assertions.assertThat(person2.getId()).isEqualTo(1000);
session.insert(person);
session.insert(person2);
session.fireAllRules();
Assertions.assertThat(person.getName()).isEqualTo("Paul");
Assertions.assertThat(person.getId()).isEqualTo(2);
Assertions.assertThat(person2.getName()).isEqualTo("Wilhelm von Seireit");
Assertions.assertThat(person2.getId()).isEqualTo(1000);
session.dispose();
}
use of org.kie.api.io.Resource in project drools by kiegroup.
the class DecisionTableTest method testSimpleCSV.
@Test
public void testSimpleCSV() {
final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("sample.csv", getClass(), DecisionTableInputType.CSV);
testSimpleDecisionTable(decisionTable);
}
use of org.kie.api.io.Resource in project drools by kiegroup.
the class DecisionTableTest method testEmptyActionInCSV.
@Test(expected = DecisionTableParseException.class)
public void testEmptyActionInCSV() {
final Resource decisionTable = ResourceUtil.getDecisionTableResourceFromClasspath("emptyAction.csv", getClass(), DecisionTableInputType.CSV);
KieUtil.getKieBuilderFromResources(kieBaseTestConfiguration, true, decisionTable);
}
Aggregations