-
Notifications
You must be signed in to change notification settings - Fork 1
more test coverage #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3c53711
Expand pipeline coverage for MatchProcessor and AvlProcessor
aaronbrethorst ce87f92
Fix NPE in HoldingTimeGeneratorDefaultImpl.getControlPointStops
aaronbrethorst abae6f9
Refresh README and explain why mvn test fails on the reactor
aaronbrethorst 0ce17ad
Address pr-review-toolkit findings on holding-time fix
aaronbrethorst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...eTests/src/test/java/org/transitclock/pipelinetests/HoldingTimeGeneratorBehaviorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package org.transitclock.pipelinetests; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.transitclock.core.holdingmethod.HoldingTimeGeneratorDefaultImpl; | ||
| import org.transitclock.db.structs.HoldingTime; | ||
| import org.transitclock.ipc.data.IpcArrivalDeparture; | ||
|
|
||
| /** | ||
| * Behavior tests for {@link HoldingTimeGeneratorDefaultImpl}. The existing | ||
| * unit test in {@code transitclock/src/test} only covers the private | ||
| * {@code calculateHoldingTime} math helper via reflection; the public | ||
| * {@code generateHoldingTime} contract had no coverage. | ||
| */ | ||
| public class HoldingTimeGeneratorBehaviorTest { | ||
|
|
||
| @ClassRule | ||
| public static final CoreHarness CORE = CoreHarness.withWmata5A(); | ||
|
|
||
| private static final String NON_CONTROL_STOP_ID = "14253"; | ||
| private static final String ROUTE_ID = "5A"; | ||
| private static final String TRIP_ID = "868588900"; | ||
|
|
||
| private static IpcArrivalDeparture event(String vehicleId, String stopId, | ||
| boolean isArrival, long epochMs) { | ||
| IpcArrivalDeparture ad = new IpcArrivalDeparture(); | ||
| ad.setVehicleId(vehicleId); | ||
| ad.setStopId(stopId); | ||
| ad.setRouteId(ROUTE_ID); | ||
| ad.setTripId(TRIP_ID); | ||
| ad.setArrival(isArrival); | ||
| ad.setTime(new Date(epochMs)); | ||
| ad.setAvlTime(new Date(epochMs)); | ||
| return ad; | ||
| } | ||
|
|
||
| // ---------- Tests ---------- | ||
|
|
||
| @Test | ||
| public void generateHoldingTime_nonArrivalEventReturnsNull() { | ||
| IpcArrivalDeparture departure = event( | ||
| "v-ht-depart", NON_CONTROL_STOP_ID, /*isArrival*/ false, | ||
| 1466437800000L); | ||
|
|
||
| HoldingTime result = new HoldingTimeGeneratorDefaultImpl() | ||
| .generateHoldingTime(/*vehicleState*/ null, departure); | ||
|
|
||
| assertThat(result) | ||
| .as("departure events must not produce a holding time") | ||
| .isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| public void generateHoldingTime_arrivalAtNonControlStopReturnsNull() { | ||
| IpcArrivalDeparture arrival = event( | ||
| "v-ht-arr-nonctrl", NON_CONTROL_STOP_ID, /*isArrival*/ true, | ||
| 1466437800000L); | ||
|
|
||
| HoldingTime result = new HoldingTimeGeneratorDefaultImpl() | ||
| .generateHoldingTime(/*vehicleState*/ null, arrival); | ||
|
|
||
| assertThat(result) | ||
| .as("arrivals at non-control stops must not produce a holding time") | ||
| .isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| public void getControlPointStops_defaultsToEmptyList() { | ||
| // Callers of getControlPointStops iterate without null-guarding, so an | ||
| // unset controlStops config must produce an empty list, not null. | ||
| assertThat(new HoldingTimeGeneratorDefaultImpl().getControlPointStops()) | ||
| .as("with no transitclock.holding.controlStops configured, " | ||
| + "getControlPointStops() must return an empty (non-null) list") | ||
| .isNotNull() | ||
| .isEmpty(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix grammar: hyphenate compound adjective.
The phrase "cost effective" should be hyphenated when used as a compound adjective before a noun.
📝 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~12-~12: Use a hyphen to join words.
Context: ...-source system, agencies can have a cost effective system and have full ownership...
(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents