Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
vpaturet committed Oct 14, 2024
1 parent a129131 commit 7644483
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class TimetableSnapshot {
* A real-time timetable overrides the scheduled timetable of a TripPattern for only a single
* service date. There can be only one overriding timetable per TripPattern and per service date.
* This is enforced by indexing the map with a pair (TripPattern, service date).
* This field will be set to null when the TimetableSnapshot becomes read-only.
* This map is cleared when the TimetableSnapshot becomes read-only.
*/
private final Map<TripPatternAndServiceDate, Timetable> dirtyTimetables = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.model;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand All @@ -20,19 +21,18 @@
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opentripplanner.ConstantsForTests;
import org.opentripplanner.TestOtpModel;
import org.opentripplanner._support.time.ZoneIds;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitLayer;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers.TransitLayerUpdater;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.framework.Result;
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripIdAndServiceDate;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
import org.opentripplanner.transit.model.timetable.TripTimes;
import org.opentripplanner.transit.model.timetable.TripTimesFactory;
Expand Down Expand Up @@ -296,18 +296,23 @@ void testUniqueDirtyTimetablesAfterMultipleUpdates() {
snapshot.update(realTimeTripUpdate);
assertTrue(snapshot.isDirty());

AtomicBoolean updateIsCalled = new AtomicBoolean();

TransitLayerUpdater transitLayer = new TransitLayerUpdater(null) {
@Override
public void update(
Collection<Timetable> updatedTimetables,
Map<TripPattern, SortedSet<Timetable>> timetables
) {
assertEquals(1, updatedTimetables.size());
assertEquals(1, timetables.size());
updateIsCalled.set(true);
assertThat(updatedTimetables).hasSize(1);
assertThat(timetables).hasSize(1);
}
};

snapshot.commit(transitLayer, true);

assertTrue(updateIsCalled.get());
}

@Test
Expand Down

0 comments on commit 7644483

Please sign in to comment.