use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testContainsShortArray.
@Test
public void testContainsShortArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Short", false, "1"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, (short) 1, new Short[] { 1, 2, 3 });
final Primitives p1 = new Primitives();
p1.setPrimitiveShortArray(new short[] { 1, 2, 3 });
p1.setShortPrimitive((short) 2);
final Primitives p2 = new Primitives();
p2.setPrimitiveShortArray(new short[] { 1, 2, 3 });
p2.setShortPrimitive((short) 1);
testArrayContains(kieSession, p1, p2, list);
} finally {
kieSession.dispose();
}
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class LiteralTest method testBigLiterals.
@Test
public void testBigLiterals() {
final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "import " + Primitives.class.getCanonicalName() + ";\n" + "rule X\n" + "when\n" + " Primitives( bigInteger == 10I, bigInteger < (50I), bigDecimal == 10B, bigDecimal < (50B) )\n" + "then\n" + "end\n";
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("literal-test", kieBaseTestConfiguration, drl);
final KieSession session = kbase.newKieSession();
try {
final Primitives p = new Primitives();
p.setBigDecimal(BigDecimal.valueOf(10));
p.setBigInteger(BigInteger.valueOf(10));
session.insert(p);
final int rulesFired = session.fireAllRules();
assertEquals(1, rulesFired);
} finally {
session.dispose();
}
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class PatternTest method testBigDecimal.
@Test
public void testBigDecimal() {
final String drl = "package org.drools.compiler.integrationtests.drl;\n" + "\n" + "import " + Cheese.class.getCanonicalName() + ";\n" + "import " + Primitives.class.getCanonicalName() + ";\n" + "import java.math.BigDecimal;\n" + "\n" + "global java.util.List list;\n" + "\n" + "rule \"BigDec\"\n" + "\n" + " when\n" + " Cheese($price : price)\n" + " p : Primitives(bigDecimal < $price)\n" + " then\n" + " list.add( p );\n" + "end";
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("pattern-test", kieBaseTestConfiguration, drl);
final KieSession session = kbase.newKieSession();
try {
final List list = new ArrayList();
session.setGlobal("list", list);
final Primitives bill = new Primitives();
bill.setBigDecimal(new BigDecimal("42"));
final Primitives ben = new Primitives();
ben.setBigDecimal(new BigDecimal("43"));
session.insert(bill);
session.insert(new Cheese("gorgonzola", 43));
session.insert(ben);
session.fireAllRules();
assertEquals(1, ((List) session.getGlobal("list")).size());
} finally {
session.dispose();
}
}
Aggregations