use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class AlphaNodeRangeIndexingTest method testBigDecimal.
@Test
public void testBigDecimal() {
final String drl = "package org.drools.compiler.test\n" + "import " + Primitives.class.getCanonicalName() + "\n" + "rule test1\n when\n" + " Primitives( bigDecimal >= 18.0 )\n" + "then\n end\n" + "rule test2\n when\n" + " Primitives( bigDecimal < 25.0 )\n" + "then\n end\n" + "rule test3\n when\n" + " Primitives( bigDecimal > 8.0 )\n" + "then\n end\n" + "rule test4\n when\n" + " Primitives( bigDecimal < 60.0 )\n" + "then\n end\n" + "rule test5\n when\n" + " Primitives( bigDecimal > 12.0 )\n" + "then\n end\n" + "rule test6\n when\n" + " Primitives( bigDecimal <= 4.0 )\n" + "then\n end\n";
final KieBase kbase = createKieBaseWithRangeIndexThresholdValue(drl, 3);
final KieSession ksession = kbase.newKieSession();
assertSinks(kbase, Primitives.class, 6, 6, 0, 6);
Primitives p1 = new Primitives();
p1.setBigDecimal(new BigDecimal("18.0"));
ksession.insert(p1);
int fired = ksession.fireAllRules();
assertEquals(5, fired);
Primitives p2 = new Primitives();
p2.setBigDecimal(new BigDecimal("60.0"));
ksession.insert(p2);
fired = ksession.fireAllRules();
assertEquals(3, fired);
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsCharArray.
@Test
public void testNotContainsCharArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Character", true, "'c'"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 'c', new Character[] { 'd', 'e', 'f' });
final Primitives p1 = new Primitives();
p1.setPrimitiveCharArray(new char[] { 'd', 'e', 'f' });
p1.setCharPrimitive('a');
final Primitives p2 = new Primitives();
p2.setPrimitiveCharArray(new char[] { 'd', 'e', 'f' });
p2.setCharPrimitive('c');
testArrayContains(kieSession, p1, p2, list);
} finally {
kieSession.dispose();
}
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testContainsIntArray.
@Test
public void testContainsIntArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Integer", false, "10"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 10, new Integer[] { 5, 10, 20 });
final Primitives p1 = new Primitives();
p1.setPrimitiveIntArray(new int[] { 5, 10, 20 });
p1.setIntPrimitive(5);
final Primitives p2 = new Primitives();
p2.setPrimitiveIntArray(new int[] { 5, 10, 20 });
p2.setIntPrimitive(10);
testArrayContains(kieSession, p1, p2, list);
} finally {
kieSession.dispose();
}
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsFloatArray.
@Test
public void testNotContainsFloatArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Float", true, "10f"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 10.0f, new Float[] { 40f, 50f, 60f });
final Primitives p1 = new Primitives();
p1.setFloatPrimitive(5);
p1.setPrimitiveFloatArray(new float[] { 40, 50, 60 });
final Primitives p2 = new Primitives();
p2.setFloatPrimitive(10);
p2.setPrimitiveFloatArray(new float[] { 40, 50, 60 });
testArrayContains(kieSession, p1, p2, list);
} finally {
kieSession.dispose();
}
}
use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testContainsBooleanArray.
@Test
public void testContainsBooleanArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Boolean", false, "true"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, true, new Boolean[] { true, false });
final Primitives p1 = new Primitives();
p1.setPrimitiveBooleanArray(new boolean[] { true, false });
p1.setBooleanPrimitive(false);
final Primitives p2 = new Primitives();
p2.setPrimitiveBooleanArray(new boolean[] { true, false });
p2.setBooleanPrimitive(true);
testArrayContains(kieSession, p1, p2, list);
} finally {
kieSession.dispose();
}
}
Aggregations