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 2020/11/17 11:16:08 UTC

[unomi] branch unomi-1.4.x updated: UNOMI-400 Fix typo bug in PropertyConditionEvaluator & improve unit test (#216)

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

shuber pushed a commit to branch unomi-1.4.x
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/unomi-1.4.x by this push:
     new fb5321c  UNOMI-400 Fix typo bug in PropertyConditionEvaluator & improve unit test (#216)
fb5321c is described below

commit fb5321cbdd43065d0c7642a8408b3b8b828c594e
Author: Serge Huber <sh...@jahia.com>
AuthorDate: Tue Nov 17 12:11:52 2020 +0100

    UNOMI-400 Fix typo bug in PropertyConditionEvaluator & improve unit test (#216)
    
    (cherry picked from commit 304649f515dacecd2f8f00222fd630c893a458fb)
---
 .../conditions/PropertyConditionEvaluator.java     |  2 +-
 .../conditions/PropertyConditionEvaluatorTest.java | 31 +++++++++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
index f68bd5c..1f9928c 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluator.java
@@ -463,7 +463,7 @@ public class PropertyConditionEvaluator implements ConditionEvaluator {
             if ("target".equals(expression)) {
                 return event.getTarget();
             } else {
-                return getItemProperty(event.getSource(), expression.substring("target".length()+1));
+                return getItemProperty(event.getTarget(), expression.substring("target".length()+1));
             }
         }
         if ("timeStamp".equals(expression)) {
diff --git a/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java b/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
index a878173..720dcff 100644
--- a/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
+++ b/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
@@ -40,8 +40,10 @@ public class PropertyConditionEvaluatorTest {
 
     public static final String MOCK_ITEM_ID = "mockItemId";
     public static final String DIGITALL_SCOPE = "digitall";
-    public static final String PAGE_PATH_VALUE = "/site/en/home/aboutus.html";
-    public static final String PAGE_URL_VALUE = "http://localhost:8080/site/en/home/aboutus.html";
+    public static final String SOURCE_PAGE_PATH_VALUE = "/site/en/home.html";
+    public static final String SOURCE_PAGE_URL_VALUE = "http://localhost:8080/site/en/home.html";
+    public static final String TARGET_PAGE_PATH_VALUE = "/site/en/home/aboutus.html";
+    public static final String TARGET_PAGE_URL_VALUE = "http://localhost:8080/site/en/home/aboutus.html";
     public static final Date SESSION_LAST_EVENT_DATE = new Date();
     public static final int THREAD_POOL_SIZE = 300;
     public static final int WORKER_COUNT = 500000;
@@ -80,11 +82,11 @@ public class PropertyConditionEvaluatorTest {
         Event mockEvent = generateMockEvent(mockProfile, mockSession);
         assertEquals("Target itemId value is not correct", MOCK_ITEM_ID, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.itemId"));
         assertEquals("Target scope is not correct", DIGITALL_SCOPE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.scope"));
-        assertEquals("Target page path value is not correct", PAGE_PATH_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
-        assertEquals("Target page url value is not correct", PAGE_URL_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.properties.pageInfo.pageURL"));
+        assertEquals("Target page path value is not correct", TARGET_PAGE_PATH_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
+        assertEquals("Target page url value is not correct", TARGET_PAGE_URL_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "target.properties.pageInfo.pageURL"));
         assertEquals("Session size should be 10", SESSION_SIZE, propertyConditionEvaluator.getHardcodedPropertyValue(mockSession, "size"));
         assertEquals("Session profile previous visit is not valid", PROFILE_PREVIOUS_VISIT, propertyConditionEvaluator.getHardcodedPropertyValue(mockSession,"profile.properties.previousVisit"));
-        assertEquals("Page page couldn't be resolved on Event property", PAGE_PATH_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "source.properties.pageInfo.pagePath"));
+        assertEquals("Page page couldn't be resolved on Event property", SOURCE_PAGE_PATH_VALUE, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "source.properties.pageInfo.pagePath"));
         assertEquals("Tracking consent should be granted", ConsentStatus.GRANTED, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "profile.consents.digitall/trackingConsentId.status"));
         assertEquals("Tracking consent should be granted", ConsentStatus.GRANTED, propertyConditionEvaluator.getHardcodedPropertyValue(mockEvent, "profile.consents[\"digitall/trackingConsentId\"].status"));
 
@@ -101,8 +103,8 @@ public class PropertyConditionEvaluatorTest {
         Event mockEvent = generateMockEvent(mockProfile, mockSession);
         assertEquals("Target itemId value is not correct", MOCK_ITEM_ID, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.itemId"));
         assertEquals("Target scope is not correct", DIGITALL_SCOPE, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.scope"));
-        assertEquals("Target page path value is not correct", PAGE_PATH_VALUE, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
-        assertEquals("Target page url value is not correct", PAGE_URL_VALUE, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.properties.pageInfo.pageURL"));
+        assertEquals("Target page path value is not correct", TARGET_PAGE_PATH_VALUE, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
+        assertEquals("Target page url value is not correct", TARGET_PAGE_URL_VALUE, propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "target.properties.pageInfo.pageURL"));
         assertEquals("Session size should be 10", SESSION_SIZE, propertyConditionEvaluator.getOGNLPropertyValue(mockSession, "size"));
         assertEquals("Should have received the proper last even date", SESSION_LAST_EVENT_DATE, propertyConditionEvaluator.getOGNLPropertyValue(mockSession, "lastEventDate"));
 
@@ -131,7 +133,7 @@ public class PropertyConditionEvaluatorTest {
         Event mockEvent = generateMockEvent(mockProfile, mockSession);
         assertEquals("Target itemId value is not correct", MOCK_ITEM_ID, propertyConditionEvaluator.getPropertyValue(mockEvent, "target.itemId"));
         assertEquals("Target scope is not correct", DIGITALL_SCOPE, propertyConditionEvaluator.getPropertyValue(mockEvent, "target.scope"));
-        assertEquals("Target page path value is not correct", PAGE_PATH_VALUE, propertyConditionEvaluator.getPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
+        assertEquals("Target page path value is not correct", TARGET_PAGE_PATH_VALUE, propertyConditionEvaluator.getPropertyValue(mockEvent, "target.properties.pageInfo.pagePath"));
 
         assertNull("Unexisting property should be null", propertyConditionEvaluator.getPropertyValue(mockSession, "systemProperties.goals._csk6r4cgeStartReached"));
         assertNull("Unexisting property should be null", propertyConditionEvaluator.getPropertyValue(mockProfile, "properties.email"));
@@ -205,15 +207,18 @@ public class PropertyConditionEvaluatorTest {
         CustomItem sourceItem = new CustomItem();
         sourceItem.setItemId(MOCK_ITEM_ID);
         sourceItem.setScope(DIGITALL_SCOPE);
-        Map<String, Object> pageInfoMap = new HashMap<>();
-        pageInfoMap.put("pagePath", PAGE_PATH_VALUE);
-        pageInfoMap.put("pageURL", PAGE_URL_VALUE);
-        sourceItem.getProperties().put("pageInfo", pageInfoMap);
+        Map<String, Object> sourcePageInfoMap = new HashMap<>();
+        sourcePageInfoMap.put("pagePath", SOURCE_PAGE_PATH_VALUE);
+        sourcePageInfoMap.put("pageURL", SOURCE_PAGE_URL_VALUE);
+        sourceItem.getProperties().put("pageInfo", sourcePageInfoMap);
         mockEvent.setSource(sourceItem);
         CustomItem targetItem = new CustomItem();
         targetItem.setItemId(MOCK_ITEM_ID);
         targetItem.setScope(DIGITALL_SCOPE);
-        targetItem.getProperties().put("pageInfo", pageInfoMap);
+        Map<String, Object> targetPageInfoMap = new HashMap<>();
+        targetPageInfoMap.put("pagePath", TARGET_PAGE_PATH_VALUE);
+        targetPageInfoMap.put("pageURL", TARGET_PAGE_URL_VALUE);
+        targetItem.getProperties().put("pageInfo", targetPageInfoMap);
         mockEvent.setTarget(targetItem);
         return mockEvent;
     }