Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
vpaturet committed May 28, 2024
1 parent 61f9fd9 commit f17eb1a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ public EstimatedCallsBuilder call(StopLocation stop) {

public EstimatedCallsBuilder arriveAimedExpected(String aimedTime, String expectedTime) {
var call = calls.getLast();
call.setAimedArrivalTime(aimedTime == null ? null : dateTimeHelper.zonedDateTime(aimedTime));
call.setExpectedArrivalTime(
expectedTime == null ? null : dateTimeHelper.zonedDateTime(expectedTime)
);
if (aimedTime != null) {
call.setAimedArrivalTime(dateTimeHelper.zonedDateTime(aimedTime));
}
if (expectedTime != null) {
call.setExpectedArrivalTime(dateTimeHelper.zonedDateTime(expectedTime));
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.opentripplanner.DateTimeHelper;
Expand Down Expand Up @@ -41,15 +40,10 @@

class SiriTimetableSnapshotSourceTest {

private RealtimeTestEnvironment env;

@BeforeEach
void setUp() {
env = new RealtimeTestEnvironment();
}

@Test
void testCancelTrip() {
var env = new RealtimeTestEnvironment();

assertEquals(RealTimeState.SCHEDULED, env.getTripTimesForTrip(env.trip1).getRealTimeState());

var updates = new SiriEtBuilder(env.getDateTimeHelper())
Expand All @@ -65,6 +59,8 @@ void testCancelTrip() {

@Test
void testAddJourney() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withEstimatedVehicleJourneyCode("newJourney")
.withIsExtraJourney(true)
Expand All @@ -85,6 +81,8 @@ void testAddJourney() {

@Test
void testReplaceJourney() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withEstimatedVehicleJourneyCode("newJourney")
.withIsExtraJourney(true)
Expand Down Expand Up @@ -117,6 +115,8 @@ void testReplaceJourney() {
*/
@Test
void testUpdateJourneyWithDatedVehicleJourneyRef() {
var env = new RealtimeTestEnvironment();

var updates = updatedJourneyBuilder(env)
.withDatedVehicleJourneyRef(env.trip1.getId().getId())
.buildEstimatedTimetableDeliveries();
Expand All @@ -130,6 +130,8 @@ void testUpdateJourneyWithDatedVehicleJourneyRef() {
*/
@Test
void testUpdateJourneyWithFramedVehicleJourneyRef() {
var env = new RealtimeTestEnvironment();

var updates = updatedJourneyBuilder(env)
.withFramedVehicleJourneyRef(builder ->
builder.withServiceDate(env.serviceDate).withVehicleJourneyRef(env.trip1.getId().getId())
Expand All @@ -145,6 +147,8 @@ void testUpdateJourneyWithFramedVehicleJourneyRef() {
*/
@Test
void testUpdateJourneyWithoutJourneyRef() {
var env = new RealtimeTestEnvironment();

var updates = updatedJourneyBuilder(env).buildEstimatedTimetableDeliveries();
var result = env.applyEstimatedTimetable(updates);
assertEquals(0, result.successful());
Expand All @@ -155,6 +159,8 @@ void testUpdateJourneyWithoutJourneyRef() {
*/
@Test
void testUpdateJourneyWithFuzzyMatching() {
var env = new RealtimeTestEnvironment();

var updates = updatedJourneyBuilder(env).buildEstimatedTimetableDeliveries();
var result = env.applyEstimatedTimetableWithFuzzyMatcher(updates);
assertEquals(1, result.successful());
Expand All @@ -167,6 +173,8 @@ void testUpdateJourneyWithFuzzyMatching() {
*/
@Test
void testUpdateJourneyWithFuzzyMatchingAndMissingAimedDepartureTime() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withFramedVehicleJourneyRef(builder ->
builder.withServiceDate(env.serviceDate).withVehicleJourneyRef("XXX")
Expand All @@ -189,6 +197,8 @@ void testUpdateJourneyWithFuzzyMatchingAndMissingAimedDepartureTime() {
*/
@Test
void testChangeQuay() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip1.getId().getId())
.withRecordedCalls(builder ->
Expand All @@ -215,6 +225,8 @@ void testChangeQuay() {

@Test
void testCancelStop() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip2.getId().getId())
.withEstimatedCalls(builder ->
Expand Down Expand Up @@ -243,6 +255,8 @@ void testCancelStop() {
@Test
@Disabled("Not supported yet")
void testAddStop() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip1.getId().getId())
.withRecordedCalls(builder ->
Expand Down Expand Up @@ -287,6 +301,8 @@ void testAddStop() {

@Test
void testNotMonitored() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withMonitored(false)
.buildEstimatedTimetableDeliveries();
Expand All @@ -298,6 +314,8 @@ void testNotMonitored() {

@Test
void testReplaceJourneyWithoutEstimatedVehicleJourneyCode() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef("newJourney")
.withIsExtraJourney(true)
Expand All @@ -321,6 +339,8 @@ void testReplaceJourneyWithoutEstimatedVehicleJourneyCode() {

@Test
void testNegativeHopTime() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip1.getId().getId())
.withRecordedCalls(builder ->
Expand All @@ -339,6 +359,8 @@ void testNegativeHopTime() {

@Test
void testNegativeDwellTime() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip2.getId().getId())
.withRecordedCalls(builder ->
Expand All @@ -362,6 +384,8 @@ void testNegativeDwellTime() {
@Test
@Disabled("Not supported yet")
void testExtraUnknownStop() {
var env = new RealtimeTestEnvironment();

var updates = new SiriEtBuilder(env.getDateTimeHelper())
.withDatedVehicleJourneyRef(env.trip1.getId().getId())
.withEstimatedCalls(builder ->
Expand Down

0 comments on commit f17eb1a

Please sign in to comment.