From d34f27face49aa33301b81d4e807cf9293dcd516 Mon Sep 17 00:00:00 2001 From: "Johan Torin (extern)" Date: Fri, 18 Oct 2024 08:07:29 +0000 Subject: [PATCH 1/2] Make the test itinerary instance non-static as it's modified in some tests. Specifically, an itinerary can be flagged for deletion in one test, which affects the assertions in the next test. Without this, tests may fail if they are executed in a certain order. This may be because LC_COLLATE is not set in the environment. --- .../filterchain/ItineraryListFilterChainTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java index 1cd19823f17..4ccb7ac9793 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/filterchain/ItineraryListFilterChainTest.java @@ -305,12 +305,12 @@ void testPostProcessorWithMaxItinerariesFilterSetToOneArriveBy() { @Nested class FlexSearchWindow { - private static final Itinerary FLEX = newItinerary(A, T11_00) + private final Itinerary flex = newItinerary(A, T11_00) .flex(T11_00, T11_30, B) .withIsSearchWindowAware(false) .build(); - private static final Instant EARLIEST_DEPARTURE = FLEX.startTime().plusMinutes(10).toInstant(); - private static final Duration SEARCH_WINDOW = Duration.ofHours(7); + private final Instant earliestDeparture = flex.startTime().plusMinutes(10).toInstant(); + private final Duration searchWindow = Duration.ofHours(7); /** * When the filtering of direct flex by the transit search window is deactivated, the direct @@ -320,18 +320,18 @@ class FlexSearchWindow { void keepDirectFlexWhenFilteringByEarliestDepartureIsDisabled() { ItineraryListFilterChain chain = createBuilder(true, false, 10) .withFilterDirectFlexBySearchWindow(false) - .withSearchWindow(EARLIEST_DEPARTURE, SEARCH_WINDOW) + .withSearchWindow(earliestDeparture, searchWindow) .build(); - assertEquals(toStr(List.of(FLEX)), toStr(chain.filter(List.of(FLEX)))); + assertEquals(toStr(List.of(flex)), toStr(chain.filter(List.of(flex)))); } @Test void removeDirectFlexWhenFilteringByEarliestDepartureIsEnabled() { ItineraryListFilterChain chain = createBuilder(true, false, 10) .withFilterDirectFlexBySearchWindow(true) - .withSearchWindow(EARLIEST_DEPARTURE, SEARCH_WINDOW) + .withSearchWindow(earliestDeparture, searchWindow) .build(); - assertEquals(toStr(List.of()), toStr(chain.filter(List.of(FLEX)))); + assertEquals(toStr(List.of()), toStr(chain.filter(List.of(flex)))); } } From 48399ccb0fbd7737f88c7a0a875bcf794c84d757 Mon Sep 17 00:00:00 2001 From: Johan Torin Date: Thu, 24 Oct 2024 13:49:59 +0200 Subject: [PATCH 2/2] Avoid making a copy of the underlying collection when checking if the Itinerary is flagged for deletion. --- .../src/main/java/org/opentripplanner/model/plan/Itinerary.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java index c3d8513c2f1..18055690b6e 100644 --- a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java +++ b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java @@ -232,7 +232,7 @@ public void removeDeletionFlags(Set removeTags) { } public boolean isFlaggedForDeletion() { - return !getSystemNotices().isEmpty(); + return !systemNotices.isEmpty(); } /**