aboutsummaryrefslogtreecommitdiffstats
path: root/policy-core/src/test/resources
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-10-05 16:06:17 -0400
committerJim Hahn <jrh3@att.com>2018-10-05 17:41:42 -0400
commit002e1441fc90a257737bc567c297faa4e65aaf3d (patch)
tree07ede0e5ecac25f3954d1fd564aa685ce526dd1d /policy-core/src/test/resources
parent07e4703c7fa8b5d400de8c328c6e4b93d536d41f (diff)
Add coverage to policy-core
Added easy junit test coverage cases. Fixed sonar issue: removed sleep from DroolsContainerTest. Fixed sonar bug in ClassExtractors. Change-Id: I942badf17c42346c1735bc3951450fc31c02a769 Issue-ID: POLICY-1148 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-core/src/test/resources')
-rw-r--r--policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/rules.drl30
-rw-r--r--policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/rules.drl37
2 files changed, 34 insertions, 33 deletions
diff --git a/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/rules.drl b/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/rules.drl
index 426c4df9..cb1bd2f6 100644
--- a/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/rules.drl
+++ b/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/rules.drl
@@ -18,6 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.policy.drools.core.test;
+
+ import java.util.concurrent.BlockingQueue;
+ import java.util.List;
rule "Initialization"
when
@@ -27,23 +30,20 @@ rule "Initialization"
}
end
-rule "Add elements of an int array"
+rule "Add elements of an int list"
when
- $object : Object()
+ $lst : List()
+ $queue : BlockingQueue()
then
{
- if ($object instanceof int[])
- {
- int[] array = (int[])($object);
-
- System.out.println("Received array of length " + array.length);
- int sum = 0;
- for (int i = 1 ; i < array.length ; i += 1)
- {
- sum += array[i];
- }
- array[0] = sum;
- retract($object);
- }
+ System.out.println("Received list of length " + $lst.size());
+ int sum = 0;
+ List<Integer> intlst = $lst;
+ for(int val: intlst) {
+ sum += val;
+ }
+ $queue.add(sum);
+ retract($lst);
+ retract($queue);
}
end
diff --git a/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/rules.drl b/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/rules.drl
index a53047a2..187767a5 100644
--- a/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/rules.drl
+++ b/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/rules.drl
@@ -18,6 +18,9 @@
* ============LICENSE_END=========================================================
*/
package org.onap.policy.drools.core.test;
+
+ import java.util.concurrent.BlockingQueue;
+ import java.util.List;
rule "Initialization"
when
@@ -27,22 +30,20 @@ rule "Initialization"
}
end
-rule "Multiply elements of an int array"
- when
- $object : Object()
- then
- {
- if ($object instanceof int[])
- {
- int[] array = (int[])($object);
-
- System.out.println("Received array of length " + array.length);
- int product = 1;
- for (int i = 1 ; i < array.length ; i += 1)
- {
- product *= array[i];
- }
- array[0] = product;
- }
- }
+rule "Multiply elements of an int list"
+ when
+ $lst : List()
+ $queue : BlockingQueue()
+ then
+ {
+ System.out.println("Received list of length " + $lst.size());
+ int prod = 1;
+ List<Integer> intlst = $lst;
+ for(int val: intlst) {
+ prod *= val;
+ }
+ $queue.add(prod);
+ retract($lst);
+ retract($queue);
+ }
end