This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new 24d0ad372 UNOMI-579 Fix Condition evaluator integration test date
calculation (#431)
24d0ad372 is described below
commit 24d0ad37256a175d2ace4812ba078abb796f9547
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.
---
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 da837e542..574c340f4 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()));