Skip to content

Commit 53b368b

Browse files
committed
SAK-50846 Sitestats: Update unit tests
1 parent d02f14f commit 53b368b

File tree

3 files changed

+981
-20
lines changed

3 files changed

+981
-20
lines changed

Diff for: sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/PresenceConsolidationTest.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import java.time.Duration;
2121
import java.time.Instant;
22+
import java.time.LocalDate;
23+
import java.time.LocalDateTime;
24+
import java.time.LocalTime;
25+
import java.time.ZoneId;
2226
import java.time.temporal.ChronoUnit;
2327
import java.util.Map;
2428

@@ -27,8 +31,6 @@
2731
import org.sakaiproject.sitestats.impl.PresenceConsolidation;
2832
import org.sakaiproject.sitestats.impl.PresenceRecord;
2933

30-
import lombok.NonNull;
31-
3234
public class PresenceConsolidationTest {
3335

3436

@@ -38,7 +40,8 @@ public void testSerialPresences() {
3840
// p1: b----e
3941
// p2: b---------e
4042
// 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();
4245
Presence presence1 = PresenceRecord.builder()
4346
.begin(base)
4447
.end(base.plus(15, ChronoUnit.MINUTES))
@@ -70,7 +73,8 @@ public void testOverlappingPresences() {
7073
// p1: b-----------------------------e
7174
// p2: b----------------------------------e
7275
// 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();
7478
Presence presence1 = PresenceRecord.builder()
7579
.begin(base)
7680
.end(base.plus(90, ChronoUnit.MINUTES))
@@ -115,7 +119,8 @@ public void testCrossDayPresences() {
115119
// p1: b-------------------------e
116120
// p2: b-----------------------------------e
117121
// 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();
119124
Instant d1 = base;
120125
Instant d2 = base.plus(1, ChronoUnit.DAYS);
121126
Instant d3 = base.plus(2, ChronoUnit.DAYS);

0 commit comments

Comments
 (0)