use of org.drools.testcoverage.common.model.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsByteArray.
@Test
public void testNotContainsByteArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Byte", true, "1"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, (byte) 1, new Byte[] { 4, 5, 6 });
final Primitives p1 = new Primitives();
p1.setPrimitiveByteArray(new byte[] { 4, 5, 6 });
p1.setBytePrimitive((byte) 2);
final Primitives p2 = new Primitives();
p2.setPrimitiveByteArray(new byte[] { 4, 5, 6 });
p2.setBytePrimitive((byte) 1);
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 testNotContainsShortArray.
@Test
public void testNotContainsShortArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Short", true, "1"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, (short) 1, new Short[] { 4, 5, 6 });
final Primitives p1 = new Primitives();
p1.setPrimitiveShortArray(new short[] { 4, 5, 6 });
p1.setShortPrimitive((short) 2);
final Primitives p2 = new Primitives();
p2.setPrimitiveShortArray(new short[] { 4, 5, 6 });
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 ArrayTest method testContainsCharArray.
@Test
public void testContainsCharArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Character", false, "'c'"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 'c', new Character[] { 'a', 'b', 'c' });
final Primitives p1 = new Primitives();
p1.setPrimitiveCharArray(new char[] { 'a', 'b', 'c' });
p1.setCharPrimitive('a');
final Primitives p2 = new Primitives();
p2.setPrimitiveCharArray(new char[] { 'a', 'b', 'c' });
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 testNotContainsIntArray.
@Test
public void testNotContainsIntArray() {
final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("array-test", kieBaseTestConfiguration, getDrl("Integer", true, "10"));
final KieSession kieSession = kbase.newKieSession();
try {
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 10, new Integer[] { 40, 50, 60 });
final Primitives p1 = new Primitives();
p1.setPrimitiveIntArray(new int[] { 40, 50, 60 });
p1.setIntPrimitive(5);
final Primitives p2 = new Primitives();
p2.setPrimitiveIntArray(new int[] { 40, 50, 60 });
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 JoinNodeRangeIndexingTest method testCoercionIntVsBigDecimal.
@Test
public void testCoercionIntVsBigDecimal() {
final String drl = "package org.drools.compiler.integrationtests;\n" + "import " + Person.class.getCanonicalName() + ";\n" + "import " + Primitives.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + "rule R\n" + "\n" + " when\n" + " Person($salary : salary)\n" + " p : Primitives(intPrimitive < $salary)\n" + " then\n" + " list.add( p );\n" + "end";
// BigDecimal is coerced to Integer
final KieBase kbase = getKieBaseWithRangeIndexOption(drl);
assertIndexedTrue(kbase, Primitives.class);
final KieSession ksession = kbase.newKieSession();
try {
final List<Primitives> list = new ArrayList<>();
ksession.setGlobal("list", list);
final Primitives i42 = new Primitives();
i42.setIntPrimitive(42);
ksession.insert(i42);
final Primitives i43 = new Primitives();
i43.setIntPrimitive(43);
ksession.insert(i43);
Person john = new Person("John");
john.setSalary(new BigDecimal("43.0"));
ksession.insert(john);
ksession.fireAllRules();
Assertions.assertThat(list).containsExactly(i42);
} finally {
ksession.dispose();
}
}
Aggregations