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; } diff --git a/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java b/assertions/src/test/java/org/opentripplanner/assertions/ItineraryAssertionsTest.java index 9ef81c8..bfd03e9 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,18 @@ 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(