aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/test')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java3
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java31
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java9
-rw-r--r--policy-management/src/test/resources/echo.drl3
4 files changed, 42 insertions, 4 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
index 26103aa2..8628830c 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
@@ -202,6 +202,9 @@ public class MavenDroolsController2Test {
when(kieSess.getKieBase()).thenReturn(kieBase);
when(kieSess.getQueryResults(QUERY, PARM1, PARM2)).thenReturn(queryResults);
+ when(kieSess.getFactHandle(FACT1_OBJECT)).thenReturn(fact1);
+ when(kieSess.getFactHandle(FACT3_OBJECT)).thenReturn(fact3);
+
when(kieSess.getObject(fact1)).thenReturn(FACT1_OBJECT);
when(kieSess.getObject(fact2)).thenReturn("");
when(kieSess.getObject(fact3)).thenReturn(FACT3_OBJECT);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
index b39276d9..a2f41bc6 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -93,6 +93,35 @@ public class MavenDroolsControllerTest {
new GsonTestUtils().compareGson(controller, MavenDroolsControllerTest.class);
}
+ @Test
+ public void testFact() throws InterruptedException {
+ DroolsController controller = createDroolsController(30000L);
+
+ Integer one = 1;
+ Integer two = 2;
+
+ Assert.assertTrue(controller.offer(one));
+ Assert.assertTrue(controller.exists(one));
+ Assert.assertFalse(controller.exists(two));
+
+ Assert.assertTrue(controller.offer(two));
+ Assert.assertTrue(controller.exists(one));
+ Assert.assertTrue(controller.exists(two));
+
+ Integer three = 3;
+ Assert.assertFalse(controller.delete(three));
+ Assert.assertTrue(controller.exists(one));
+ Assert.assertTrue(controller.exists(two));
+
+ Assert.assertTrue(controller.delete(two));
+ Assert.assertTrue(controller.exists(one));
+ Assert.assertFalse(controller.exists(two));
+
+ Assert.assertTrue(controller.delete(one));
+ Assert.assertFalse(controller.exists(one));
+ Assert.assertFalse(controller.exists(two));
+ }
+
private DroolsController createDroolsController(long courtesyStartTimeMs) throws InterruptedException {
if (releaseId == null) {
throw new IllegalStateException("no prereq artifact installed in maven repository");
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
index 743de8f9..010056bb 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,4 +157,11 @@ public class NullDroolsControllerTest {
public void factQuery() {
Assert.assertTrue(new NullDroolsController().factQuery(null, null, null, false).isEmpty());
}
+
+ @Test
+ public void exists() {
+ Object o1 = new Object();
+ Assert.assertFalse(new NullDroolsController().exists("blah", o1));
+ Assert.assertFalse(new NullDroolsController().exists(o1));
+ }
}
diff --git a/policy-management/src/test/resources/echo.drl b/policy-management/src/test/resources/echo.drl
index bd26f95b..03716d96 100644
--- a/policy-management/src/test/resources/echo.drl
+++ b/policy-management/src/test/resources/echo.drl
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,5 +35,4 @@ when
$o : Object();
then
System.out.println("ECHO: " + $o.toString());
- retract($o);
end