Skip to content

Commit

Permalink
Make the test itinerary instance non-static as it's modified in some …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
jtorin committed Oct 22, 2024
1 parent 15ba54a commit d34f27f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))));
}
}

Expand Down

0 comments on commit d34f27f

Please sign in to comment.