use of io.vertx.rxjava.core.eventbus.EventBus in project rulesservice by genny-project.
the class KieTest method setupKieSessionTest.
@Test
public void setupKieSessionTest() {
String rule = "";
rule += "package org.kie.test\n";
rule += "global java.util.List list\n";
rule += "rule rule1\n";
rule += "when\n";
rule += " Integer(intValue > 0)\n";
rule += "then\n";
rule += " list.add( 1 );\n";
rule += " System.out.println(\"Added!\");\n";
rule += "end\n";
rule += "\n";
String rulesGroup = "GRP_RULES_TEST";
List<Tuple3<String, String, String>> rules = new ArrayList<Tuple3<String, String, String>>();
rules.add(Tuple.of("genny", "rule1.drl", rule));
List<Tuple2<String, Object>> globals = new ArrayList<Tuple2<String, Object>>();
List<?> list = new ArrayList<Object>();
globals.add(Tuple.of("list", list));
RulesLoader.setupKieRules(rulesGroup, rules);
Map<String, KieBase> cache = RulesLoader.getKieBaseCache();
Integer count = cache.size();
System.out.println("Loaded Test Kie Session with " + count + " ruleGroups");
EventBus eb = null;
List<Object> facts = new ArrayList<Object>();
facts.add(1);
facts.add(2);
facts.add(3);
Map<String, String> keyvalue = new HashMap<String, String>();
keyvalue.put("token", null);
RulesLoader.executeStatefull(rulesGroup, eb, globals, facts, keyvalue);
assertThat(list.size(), is(3));
}
Aggregations