19
19
20
20
import java .time .Duration ;
21
21
import java .time .Instant ;
22
+ import java .time .LocalDate ;
23
+ import java .time .LocalDateTime ;
24
+ import java .time .LocalTime ;
25
+ import java .time .ZoneId ;
22
26
import java .time .temporal .ChronoUnit ;
23
27
import java .util .Map ;
24
28
27
31
import org .sakaiproject .sitestats .impl .PresenceConsolidation ;
28
32
import org .sakaiproject .sitestats .impl .PresenceRecord ;
29
33
30
- import lombok .NonNull ;
31
-
32
34
public class PresenceConsolidationTest {
33
35
34
36
@@ -38,7 +40,8 @@ public void testSerialPresences() {
38
40
// p1: b----e
39
41
// p2: b---------e
40
42
// p3: b---------e
41
- Instant base = Instant .now ();
43
+ LocalDateTime midnight = LocalDateTime .of (LocalDate .now (), LocalTime .MIDNIGHT );
44
+ Instant base = midnight .atZone (ZoneId .systemDefault ()).toInstant ();
42
45
Presence presence1 = PresenceRecord .builder ()
43
46
.begin (base )
44
47
.end (base .plus (15 , ChronoUnit .MINUTES ))
@@ -70,7 +73,8 @@ public void testOverlappingPresences() {
70
73
// p1: b-----------------------------e
71
74
// p2: b----------------------------------e
72
75
// p3: b---------e
73
- Instant base = Instant .now ();
76
+ LocalDateTime midnight = LocalDateTime .of (LocalDate .now (), LocalTime .MIDNIGHT );
77
+ Instant base = midnight .atZone (ZoneId .systemDefault ()).toInstant ();
74
78
Presence presence1 = PresenceRecord .builder ()
75
79
.begin (base )
76
80
.end (base .plus (90 , ChronoUnit .MINUTES ))
@@ -115,7 +119,8 @@ public void testCrossDayPresences() {
115
119
// p1: b-------------------------e
116
120
// p2: b-----------------------------------e
117
121
// p3: b----------e
118
- Instant base = PresenceConsolidation .toDay (Instant .now ());
122
+ LocalDateTime midnight = LocalDateTime .of (LocalDate .now (), LocalTime .MIDNIGHT );
123
+ Instant base = midnight .atZone (ZoneId .systemDefault ()).toInstant ();
119
124
Instant d1 = base ;
120
125
Instant d2 = base .plus (1 , ChronoUnit .DAYS );
121
126
Instant d3 = base .plus (2 , ChronoUnit .DAYS );
0 commit comments