use of org.drools.compiler.Primitives in project drools by kiegroup.
the class ArrayTest method testContainsFloatArray.
@Test
public void testContainsFloatArray() throws Exception {
final KieSession kieSession = createKieSessionFromDrl(getDrl("Float", false, "10"));
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 10.0f, new Float[] { 5f, 10f, 20f });
final Primitives p1 = new Primitives();
p1.setFloatPrimitive(5);
p1.setPrimitiveFloatArray(new float[] { 5, 10, 20 });
final Primitives p2 = new Primitives();
p2.setFloatPrimitive(10);
p2.setPrimitiveFloatArray(new float[] { 5, 10, 20 });
testArrayContains(kieSession, p1, p2, list);
}
use of org.drools.compiler.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsCharArray.
@Test
public void testNotContainsCharArray() throws Exception {
final KieSession kieSession = createKieSessionFromDrl(getDrl("Character", true, "'c'"));
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);
}
use of org.drools.compiler.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsDoubleArray.
@Test
public void testNotContainsDoubleArray() throws Exception {
final KieSession kieSession = createKieSessionFromDrl(getDrl("Double", true, "10"));
final List list = new ArrayList();
addGlobalsToSession(kieSession, list, 10.0d, new Double[] { 40d, 50d, 60d });
final Primitives p1 = new Primitives();
p1.setPrimitiveDoubleArray(new double[] { 40, 50, 60 });
p1.setDoublePrimitive(5);
final Primitives p2 = new Primitives();
p2.setDoublePrimitive(10);
p2.setPrimitiveDoubleArray(new double[] { 40, 50, 60 });
testArrayContains(kieSession, p1, p2, list);
}
use of org.drools.compiler.Primitives in project drools by kiegroup.
the class ArrayTest method testNotContainsFloatArray.
@Test
public void testNotContainsFloatArray() throws Exception {
final KieSession kieSession = createKieSessionFromDrl(getDrl("Float", true, "10"));
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);
}
use of org.drools.compiler.Primitives in project drools by kiegroup.
the class ArrayTest method testPrimitiveArray.
@Test
public void testPrimitiveArray() throws Exception {
final KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("test_primitiveArray.drl"));
KieSession session = createKnowledgeSession(kbase);
List result = new ArrayList();
session.setGlobal("result", result);
final Primitives p1 = new Primitives();
p1.setPrimitiveIntArray(new int[] { 1, 2, 3 });
p1.setArrayAttribute(new String[] { "a", "b" });
session.insert(p1);
session = SerializationHelper.getSerialisedStatefulKnowledgeSession(session, true);
result = (List) session.getGlobal("result");
session.fireAllRules();
assertEquals(3, result.size());
assertEquals(3, ((Integer) result.get(0)).intValue());
assertEquals(2, ((Integer) result.get(1)).intValue());
assertEquals(3, ((Integer) result.get(2)).intValue());
}
Aggregations