Search in sources :

Example 6 with Primitives

use of org.drools.compiler.Primitives in project drools by kiegroup.

the class ArrayTest method testContainsDoubleArray.

@Test
public void testContainsDoubleArray() throws Exception {
    final KieSession kieSession = createKieSessionFromDrl(getDrl("Double", false, "10"));
    final List list = new ArrayList();
    addGlobalsToSession(kieSession, list, 10.0d, new Double[] { 5d, 10d, 20d });
    final Primitives p1 = new Primitives();
    p1.setPrimitiveDoubleArray(new double[] { 5, 10, 20 });
    p1.setDoublePrimitive(5);
    final Primitives p2 = new Primitives();
    p2.setDoublePrimitive(10);
    p2.setPrimitiveDoubleArray(new double[] { 5, 10, 20 });
    testArrayContains(kieSession, p1, p2, list);
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Primitives(org.drools.compiler.Primitives) Test(org.junit.Test)

Example 7 with Primitives

use of org.drools.compiler.Primitives in project drools by kiegroup.

the class ArrayTest method testContainsLongArray.

@Test
public void testContainsLongArray() throws Exception {
    final KieSession kieSession = createKieSessionFromDrl(getDrl("Long", false, "10"));
    final List list = new ArrayList();
    addGlobalsToSession(kieSession, list, 10L, new Long[] { 5L, 10L, 20L });
    final Primitives p1 = new Primitives();
    p1.setPrimitiveLongArray(new long[] { 5, 10, 20 });
    p1.setLongPrimitive(5);
    final Primitives p2 = new Primitives();
    p2.setLongPrimitive(10);
    p2.setPrimitiveLongArray(new long[] { 5, 10, 20 });
    testArrayContains(kieSession, p1, p2, list);
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Primitives(org.drools.compiler.Primitives) Test(org.junit.Test)

Example 8 with Primitives

use of org.drools.compiler.Primitives in project drools by kiegroup.

the class ArrayTest method testNotContainsIntArray.

@Test
public void testNotContainsIntArray() throws Exception {
    final KieSession kieSession = createKieSessionFromDrl(getDrl("Integer", true, "10"));
    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);
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Primitives(org.drools.compiler.Primitives) Test(org.junit.Test)

Example 9 with Primitives

use of org.drools.compiler.Primitives in project drools by kiegroup.

the class ArrayTest method testNotContainsShortArray.

@Test
public void testNotContainsShortArray() throws Exception {
    final KieSession kieSession = createKieSessionFromDrl(getDrl("Short", true, "1"));
    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);
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Primitives(org.drools.compiler.Primitives) Test(org.junit.Test)

Example 10 with Primitives

use of org.drools.compiler.Primitives in project drools by kiegroup.

the class ArrayTest method testNotContainsByteArray.

@Test
public void testNotContainsByteArray() throws Exception {
    final KieSession kieSession = createKieSessionFromDrl(getDrl("Byte", true, "1"));
    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);
}
Also used : ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Primitives(org.drools.compiler.Primitives) Test(org.junit.Test)

Aggregations

Primitives (org.drools.compiler.Primitives)27 Test (org.junit.Test)27 KieSession (org.kie.api.runtime.KieSession)27 ArrayList (java.util.ArrayList)23 List (java.util.List)23 KieBase (org.kie.api.KieBase)10 FactHandle (org.kie.api.runtime.rule.FactHandle)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Person (org.drools.compiler.Person)1 PersonInterface (org.drools.compiler.PersonInterface)1 IteratorToList (org.drools.compiler.integrationtests.IteratorToList)1 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)1 KiePackage (org.kie.api.definition.KiePackage)1