You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2021/06/25 13:25:53 UTC

[unomi] branch UNOMI-492-fix-rule-null-actions updated: UNOMI-492 Simplify and improve integration test

This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch UNOMI-492-fix-rule-null-actions
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/UNOMI-492-fix-rule-null-actions by this push:
     new 77b58de  UNOMI-492 Simplify and improve integration test
77b58de is described below

commit 77b58de4fb6e26d7d4910592535cbac32b7f419e
Author: Serge Huber <sh...@jahia.com>
AuthorDate: Fri Jun 25 15:25:45 2021 +0200

    UNOMI-492 Simplify and improve integration test
---
 .../java/org/apache/unomi/itests/RuleServiceIT.java   | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java b/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
index 2dfc21b..ee25a09 100644
--- a/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/RuleServiceIT.java
@@ -28,9 +28,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 /**
  * Integration tests for the Unomi rule service.
@@ -61,8 +61,6 @@ public class RuleServiceIT extends BaseIT {
 
     @Test
     public void testRuleWithNullActions() throws InterruptedException {
-        Set<Metadata> ruleMetadatas = rulesService.getRuleMetadatas();
-        int initialRuleCount = ruleMetadatas.size();
         Metadata metadata = new Metadata(TEST_RULE_ID);
         metadata.setName(TEST_RULE_ID + "_name");
         metadata.setDescription(TEST_RULE_ID + "_description");
@@ -71,15 +69,10 @@ public class RuleServiceIT extends BaseIT {
         nullRule.setCondition(null);
         nullRule.setActions(null);
         rulesService.setRule(nullRule);
-        LOGGER.info("Waiting for rules to refresh from persistence...");
-        int loopCount = 0;
-        int lastRuleCount = initialRuleCount;
-        while (loopCount < 20 && lastRuleCount == initialRuleCount) {
-            Thread.sleep(1000);
-            ruleMetadatas = rulesService.getRuleMetadatas();
-            lastRuleCount = ruleMetadatas.size();
-            loopCount++;
-        }
-        assertEquals("Rule not properly saved", initialRuleCount + 1, lastRuleCount);
+        refreshPersistence();
+        nullRule = rulesService.getRule(TEST_RULE_ID);
+        assertNull("Expected rule actions to be null", nullRule.getActions());
+        assertNull("Expected rule condition to be null", nullRule.getCondition());
+        assertEquals("Invalid rule name", TEST_RULE_ID + "_name", nullRule.getMetadata().getName());
     }
 }