@Test @RulesMustFire(ruleNames = {"Pricing bracket_18", "Discounts_34"}) public void testDT() { // now create some test data Driver driver = new Driver(); Policy policy = new Policy(); ksession.execute(Arrays.asList(new Object[] {driver, policy})); assertEquals(120, policy.getBasePrice()); assertEquals(20, policy.getDiscountPercent()); }
@Test public void testArrays() throws Exception { String text = "package test_mvel;\n"; text += "import " + TestObject.class.getCanonicalName() + ";\n"; text += "import function " + TestObject.class.getCanonicalName() + ".array;\n"; text += "no-loop true\n"; text += "dialect \"mvel\"\n"; text += "rule \"1\"\n"; text += "salience 1\n"; text += "when\n"; text += " $fact: TestObject()\n"; text += " eval($fact.checkHighestPriority(\"mvel\", 2))\n"; text += " eval($fact.stayHasDaysOfWeek(\"mvel\", false, new String[][]{{\"2008-04-01\", \"2008-04-10\"}}))\n"; text += "then\n"; text += " $fact.applyValueAddPromo(1,2,3,4,\"mvel\");\n"; text += "end"; KieBase kieBase = loadKnowledgeBaseFromString(text.replaceAll("mvel", "java"), text); StatelessKieSession statelessKieSession = kieBase.newStatelessKieSession(); List<String> list = new ArrayList<String>(); statelessKieSession.execute(new TestObject(list)); assertEquals(6, list.size()); assertTrue( list.containsAll( Arrays.asList( "TestObject.checkHighestPriority: java|2", "TestObject.stayHasDaysOfWeek: java|false|[2008-04-01, 2008-04-10]", "TestObject.checkHighestPriority: mvel|2", "TestObject.stayHasDaysOfWeek: mvel|false|[2008-04-01, 2008-04-10]", "TestObject.applyValueAddPromo: 1|2|3|4|mvel", "TestObject.applyValueAddPromo: 1|2|3|4|java"))); }