Skip to content

Commit

Permalink
bug fix on point in time service date checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonabrown committed Jan 12, 2024
1 parent dcfaaa8 commit 526b879
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public boolean isLocalizedServiceIdActiveInRange(LocalizedServiceId localizedSer
boolean active = isLocalizedServiceIdActiveOnDate(localizedServiceId, agencyServiceInterval.getServiceDate().getAsDate());
if (active) {
// even if a match is found enforce overlap in service intervals
if ( Math.max(activeService.getMinArrival(), serviceInterval.getMinArrival())
< Math.min(activeService.getMaxDeparture(), serviceInterval.getMaxDeparture())) {
if (Math.max(activeService.getMinArrival(), serviceInterval.getMinArrival())
<= Math.min(activeService.getMaxDeparture(), serviceInterval.getMaxDeparture())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,13 @@ public void testAgencyOverrideOverlap() {
// 5 + 1 service interval
AgencyServiceInterval fiveOclock1HourQuery = new AgencyServiceInterval(baseTime + hourToSec(5)*1000, oneHourOverride);
active = service.isLocalizedServiceIdActiveInRange(lsid1, sixOclockScheudledService, fiveOclock1HourQuery);
assertFalse(active);
assertTrue(active);

// active service 6:00 -> 7:00
// 7 + 1 service interval
AgencyServiceInterval sevenOclock1HourQuery = new AgencyServiceInterval(baseTime + hourToSec(7)*1000, oneHourOverride);
active = service.isLocalizedServiceIdActiveInRange(lsid1, sixOclockScheudledService, sevenOclock1HourQuery);
assertFalse(active);
assertTrue(active);

// active service 6:00 -> 7:00
// 5 + 2 service interval
Expand All @@ -483,6 +483,13 @@ public void testAgencyOverrideOverlap() {
ServiceInterval exactMatchInterval = new ServiceInterval(hourToSec(6), hourToSec(25));
active = service.isLocalizedServiceIdActiveInRange(lsid1, exactMatchInterval, lunchInterval1HourOverride);
assertTrue(active);

// point in time
AgencyServiceInterval stopCheck = new AgencyServiceInterval(baseTime + 43200, oneHourOverride);
ServiceInterval stopInterval = new ServiceInterval(43230,43230);
active = service.isLocalizedServiceIdActiveInRange(lsid1, stopInterval, lunchInterval1HourOverride);
assertTrue(active);

}

@Test
Expand Down

0 comments on commit 526b879

Please sign in to comment.