From def7a459665330f5d22fec2ff798de6c84456401 Mon Sep 17 00:00:00 2001 From: danielhep Date: Mon, 16 Mar 2026 01:56:35 -0700 Subject: [PATCH 1/3] fix error in handling fp with null price --- .../java/org/opentripplanner/assertions/ItineraryAssertions.java | 1 + 1 file changed, 1 insertion(+) diff --git a/assertions/src/main/java/org/opentripplanner/assertions/ItineraryAssertions.java b/assertions/src/main/java/org/opentripplanner/assertions/ItineraryAssertions.java index f375851..3ef6533 100644 --- a/assertions/src/main/java/org/opentripplanner/assertions/ItineraryAssertions.java +++ b/assertions/src/main/java/org/opentripplanner/assertions/ItineraryAssertions.java @@ -78,6 +78,7 @@ public ItineraryAssertions withFarePrice(float price, String riderCategoryId, St .filter(fp -> fp.product().medium().isPresent()) .filter(fp -> fp.product().riderCategory().get().id().equals(riderCategoryId)) .filter(fp -> fp.product().medium().get().id().equals(mediumId)) + .filter(fp -> fp.product().price() != null) .anyMatch(fp -> fp.product().price().amount().floatValue() == price)); return this; } From 46eeba8d5a0c97acd692979c72968883a8cf2ca0 Mon Sep 17 00:00:00 2001 From: danielhep Date: Tue, 17 Mar 2026 17:43:59 +0800 Subject: [PATCH 2/3] test null price fare produxt --- .../assertions/ItineraryAssertionsTest.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java b/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java index 9ef81c8..30bb4f4 100644 --- a/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java +++ b/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java @@ -131,7 +131,8 @@ void partialMatchesAndErrorDetailsAreIncluded() { @Test void withFarePriceHandlesPositiveAndNegativeMatches() { - List fares = List.of(fare(2.75f, "orca:regular", "orca:cash")); + List fares = List.of(fare("orca:regular", "orca:cash"), + fare(2.75f, "orca:regular", "orca:cash")); TripPlan plan = tripPlan(itinerary(transitLeg("E", "E Line", LegMode.BUS, Duration.ofMinutes(12), fares))); @@ -236,7 +237,17 @@ private static Place place(String name) { name, 10.0f, 10.0f, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); } - private static FareProductUse fare(float amount, String riderCategoryId, String mediumId) { + private static FareProductUse fare(String riderCategoryId, String mediumId) { + return new FareProductUse( + "fare-" + riderCategoryId + "-" + mediumId, + new FareProductUse.FareProduct( + "product-" + riderCategoryId + "-" + mediumId, + "Test fare", + null, + Optional.of(new FareProductUse.FareProduct.RiderCategory(riderCategoryId, "Rider")), + Optional.of(new FareProductUse.FareProduct.FareMedium(mediumId, "Medium")))); + } + private static FareProductUse fare(Float amount, String riderCategoryId, String mediumId) { return new FareProductUse( "fare-" + riderCategoryId + "-" + mediumId, new FareProductUse.FareProduct( From 00bd838494775f4c499e7c0283c82dadb92d9cb6 Mon Sep 17 00:00:00 2001 From: danielhep Date: Tue, 17 Mar 2026 17:56:52 +0800 Subject: [PATCH 3/3] add test for null price fp --- .../assertions/ItineraryAssertionsTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java b/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java index 30bb4f4..bfd03e9 100644 --- a/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java +++ b/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java @@ -131,8 +131,8 @@ void partialMatchesAndErrorDetailsAreIncluded() { @Test void withFarePriceHandlesPositiveAndNegativeMatches() { - List fares = List.of(fare("orca:regular", "orca:cash"), - fare(2.75f, "orca:regular", "orca:cash")); + List fares = + List.of(fare("orca:regular", "orca:cash"), fare(2.75f, "orca:regular", "orca:cash")); TripPlan plan = tripPlan(itinerary(transitLeg("E", "E Line", LegMode.BUS, Duration.ofMinutes(12), fares))); @@ -239,14 +239,15 @@ private static Place place(String name) { private static FareProductUse fare(String riderCategoryId, String mediumId) { return new FareProductUse( - "fare-" + riderCategoryId + "-" + mediumId, - new FareProductUse.FareProduct( - "product-" + riderCategoryId + "-" + mediumId, - "Test fare", - null, - Optional.of(new FareProductUse.FareProduct.RiderCategory(riderCategoryId, "Rider")), - Optional.of(new FareProductUse.FareProduct.FareMedium(mediumId, "Medium")))); + "fare-" + riderCategoryId + "-" + mediumId, + new FareProductUse.FareProduct( + "product-" + riderCategoryId + "-" + mediumId, + "Test fare", + null, + Optional.of(new FareProductUse.FareProduct.RiderCategory(riderCategoryId, "Rider")), + Optional.of(new FareProductUse.FareProduct.FareMedium(mediumId, "Medium")))); } + private static FareProductUse fare(Float amount, String riderCategoryId, String mediumId) { return new FareProductUse( "fare-" + riderCategoryId + "-" + mediumId,