This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.6.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.6.x by this push:
new 93afa4915 UNOMI-579 Fix Condition evaluator integration test date
calculation (#431)
93afa4915 is described below
commit 93afa491500c427aa3f1d16d64cea837a7e365d2
Author: Serge Huber <[email protected]>
AuthorDate: Wed Jun 1 10:22:03 2022 +0200
UNOMI-579 Fix Condition evaluator integration test date calculation (#431)
* 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.
* 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.
(cherry picked from commit 24d0ad37256a175d2ace4812ba078abb796f9547)
---
itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java | 3 ++-
1 file changed, 2 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 749fc716e..bf7775065 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ConditionEvaluatorIT.java
@@ -118,7 +118,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()));