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 2022/05/31 16:01:44 UTC

[unomi] branch UNOMI-579-fix-conditionevaluator-dates created (now 4a086474a)

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

shuber pushed a change to branch UNOMI-579-fix-conditionevaluator-dates
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at 4a086474a UNOMI-579 Fix issue with testDate on Condition evaluator integration tests - Added a 1h increment to compensate for daylight saving time messing with the day interval calculation.

This branch includes the following new commits:

     new 4a086474a UNOMI-579 Fix issue with testDate on Condition evaluator integration tests - Added a 1h increment to compensate for daylight saving time messing with the day interval calculation.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: UNOMI-579 Fix issue with testDate on Condition evaluator integration tests - Added a 1h increment to compensate for daylight saving time messing with the day interval calculation.

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch UNOMI-579-fix-conditionevaluator-dates
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 4a086474aecce6565c46f743472f3d5c76233ea2
Author: Serge Huber <sh...@jahia.com>
AuthorDate: Tue May 31 18:01:38 2022 +0200

    UNOMI-579 Fix issue with testDate on Condition evaluator integration tests
    - Added a 1h increment to compensate for daylight saving time messing with the day interval calculation.
---
 .../src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java b/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java
index da837e542..6b3fe9fa5 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java
@@ -23,6 +23,7 @@ import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.services.DefinitionsService;
 import org.apache.unomi.persistence.spi.PersistenceService;
+import org.apache.unomi.plugins.baseplugin.conditions.PropertyConditionEvaluator;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -118,7 +119,8 @@ public class ConditionEvaluatorIT extends BaseIT {
 
         assertTrue(eval(builder.profileProperty("properties.lastVisit").isDay(lastVisit).build()));
         assertTrue(eval(builder.profileProperty("properties.lastVisit").isNotDay(new Date(lastVisit.getTime() + (24*60*60*1000))).build()));
-        long daysFromToday = TimeUnit.MILLISECONDS.toDays(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH).getTime() - DateUtils.truncate(lastVisit, Calendar.DAY_OF_MONTH).getTime());
+        // we add one hour to the current time to compensate for differences due to Daylight Saving Time.
+        long daysFromToday = TimeUnit.MILLISECONDS.toDays(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH).getTime()+60*60*1000 - DateUtils.truncate(lastVisit, Calendar.DAY_OF_MONTH).getTime());
         assertTrue(eval(builder.profileProperty("properties.lastVisit").isDay("now-" + daysFromToday + "d").build()));
         assertTrue(eval(builder.profileProperty("properties.lastVisit").isNotDay("now-" + (daysFromToday + 1) + "d").build()));
         assertTrue(eval(builder.profileProperty("properties.lastVisit").inDateExpr("" + lastVisit.getTime()).build()));