Skip to content

Commit

Permalink
SAK-50846 Sitestats: Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
st-manu committed Jan 27, 2025
1 parent b6686be commit e762754
Show file tree
Hide file tree
Showing 3 changed files with 981 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Map;

Expand All @@ -27,8 +31,6 @@
import org.sakaiproject.sitestats.impl.PresenceConsolidation;
import org.sakaiproject.sitestats.impl.PresenceRecord;

import lombok.NonNull;

public class PresenceConsolidationTest {


Expand All @@ -38,7 +40,8 @@ public void testSerialPresences() {
// p1: b----e
// p2: b---------e
// p3: b---------e
Instant base = Instant.now();
LocalDateTime midnight = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
Instant base = midnight.atZone(ZoneId.systemDefault()).toInstant();
Presence presence1 = PresenceRecord.builder()
.begin(base)
.end(base.plus(15, ChronoUnit.MINUTES))
Expand Down Expand Up @@ -70,7 +73,8 @@ public void testOverlappingPresences() {
// p1: b-----------------------------e
// p2: b----------------------------------e
// p3: b---------e
Instant base = Instant.now();
LocalDateTime midnight = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
Instant base = midnight.atZone(ZoneId.systemDefault()).toInstant();
Presence presence1 = PresenceRecord.builder()
.begin(base)
.end(base.plus(90, ChronoUnit.MINUTES))
Expand Down Expand Up @@ -115,7 +119,8 @@ public void testCrossDayPresences() {
// p1: b-------------------------e
// p2: b-----------------------------------e
// p3: b----------e
Instant base = PresenceConsolidation.toDay(Instant.now());
LocalDateTime midnight = LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT);
Instant base = midnight.atZone(ZoneId.systemDefault()).toInstant();
Instant d1 = base;
Instant d2 = base.plus(1, ChronoUnit.DAYS);
Instant d3 = base.plus(2, ChronoUnit.DAYS);
Expand Down
Loading

0 comments on commit e762754

Please sign in to comment.