Search in sources :

Example 36 with ValidationRule

use of edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule in project gtfs-realtime-validator by CUTR-at-USF.

the class StopTimeUpdateValidatorTest method testE45.

/**
 * E045 - GTFS-rt stop_time_update stop_sequence and stop_id do not match GTFS
 */
@Test
public void testE45() {
    /**
     * bullrunner-gtfs.zip (bullRunnerGtfs) has the following in stop_times.txt:
     *
     * trip_id,arrival_time,departure_time,stop_id,stop_sequence
     * 1,07:00:00,07:00:00,222,1
     * 1,07:01:04,07:01:04,230,2
     * 1,07:01:38,07:01:38,214,3
     * 1,07:02:15,07:02:15,204,4
     * 1,07:02:56,07:02:56,102,5
     * 1,07:03:38,07:03:38,101,6
     * 1,07:04:04,07:04:04,108,7
     * 1,07:04:32,07:04:32,110,8
     * 1,07:05:38,07:05:38,166,9
     * 1,07:06:44,07:06:44,162,10
     * 1,07:07:48,07:07:48,158,11
     * 1,07:08:30,07:08:30,154,12
     * 1,07:09:20,07:09:20,150,13
     * 1,07:09:52,07:09:52,446,14
     * 1,07:11:01,07:11:01,432,15
     * 1,07:11:49,07:11:49,430,16
     * 1,07:12:34,07:12:34,426,17
     * 1,07:13:41,07:13:41,418,18
     * 1,07:14:34,07:14:34,401,19
     * 1,07:16:07,07:16:07,414,20
     * 1,07:16:53,07:16:53,330,21
     * 1,07:17:21,07:17:21,328,22
     * 1,07:17:59,07:17:59,326,23
     * 1,07:18:43,07:18:43,226,24
     * 1,07:19:43,07:19:43,222,25
     */
    StopTimeUpdateValidator stopSequenceValidator = new StopTimeUpdateValidator();
    Map<ValidationRule, Integer> expected = new HashMap<>();
    GtfsRealtime.TripUpdate.StopTimeUpdate.Builder stopTimeUpdateBuilder = GtfsRealtime.TripUpdate.StopTimeUpdate.newBuilder();
    GtfsRealtime.TripDescriptor.Builder tripDescriptorBuilder = GtfsRealtime.TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1");
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.SCHEDULED);
    // tripDescriptor is a required field in tripUpdate
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    // stop_sequence and stop_id pairings all correctly match GTFS - no errors
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // first stop_sequence and stop_id pairing is wrong - 1 error
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(1);
    // Wrong
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 1);
    TestUtils.assertResults(expected, results);
    // first two stop_sequence and stop_id pairings are wrong - 2 error
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(1);
    // Wrong
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    // Wrong
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 2);
    TestUtils.assertResults(expected, results);
    // first and third stop_sequence and stop_id pairings are wrong - 2 errors
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(1);
    // Wrong
    stopTimeUpdateBuilder.setStopId("240");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    // Wrong
    stopTimeUpdateBuilder.setStopId("240");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 2);
    TestUtils.assertResults(expected, results);
    // Third and fourth stop_sequence and stop_id pairings are wrong - 2 errors
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    // Wrong
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    // Wrong
    stopTimeUpdateBuilder.setStopId("201");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 2);
    TestUtils.assertResults(expected, results);
    // start at stop_sequence 2 - stop_sequence and stop_id pairings all correctly match GTFS - no errors
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // start at stop_sequence 2 - stop_sequence 10 is wrong - 1 error
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    // Wrong
    stopTimeUpdateBuilder.setStopId("160");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 1);
    TestUtils.assertResults(expected, results);
    // start at stop_sequence 2 - stop_sequence 10 and 25 are wrong - 2 errors
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    // Wrong
    stopTimeUpdateBuilder.setStopId("160");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    // Wrong
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E045, 2);
    TestUtils.assertResults(expected, results);
    // start at stop_sequence 2 - no stop_ids - no errors
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clearStopId();
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // no stop_sequences - no errors for E45, but does include 1 E009 error for not including stop_sequence for loop route
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clearStopSequence();
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E009, 1);
    TestUtils.assertResults(expected, results);
    clearAndInitRequiredFeedFields();
}
Also used : HashMap(java.util.HashMap) StopTimeUpdateValidator(edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.StopTimeUpdateValidator) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) GtfsRealtime(com.google.transit.realtime.GtfsRealtime) Test(org.junit.Test) FeedMessageTest(edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest)

Example 37 with ValidationRule

use of edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule in project gtfs-realtime-validator by CUTR-at-USF.

the class StopTimeUpdateValidatorTest method testE42.

/**
 * E042 - arrival or departure provided for NO_DATA stop_time_update
 */
@Test
public void testE42() {
    StopTimeUpdateValidator stopSequenceValidator = new StopTimeUpdateValidator();
    Map<ValidationRule, Integer> expected = new HashMap<>();
    GtfsRealtime.TripUpdate.StopTimeUpdate.Builder stopTimeUpdateBuilder = GtfsRealtime.TripUpdate.StopTimeUpdate.newBuilder();
    GtfsRealtime.TripDescriptor.Builder tripDescriptorBuilder = GtfsRealtime.TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1");
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.SCHEDULED);
    // tripDescriptor is a required field in tripUpdate
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    // One stop_time_update with schedule_relationship SCHEDULED and a departure - 0 errors
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setStopId("1.1");
    stopTimeUpdateBuilder.setDeparture(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    // StopTimeUpdate count should be 1
    assertEquals(1, feedMessageBuilder.getEntity(0).getTripUpdate().getStopTimeUpdateCount());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // One stop_time_update with schedule_relationship SCHEDULED and an arrival - 0 errors
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setStopId("1.1");
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.clearStopTimeUpdate();
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED);
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    // StopTimeUpdate count should be 1
    assertEquals(1, feedMessageBuilder.getEntity(0).getTripUpdate().getStopTimeUpdateCount());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // One stop_time_update with schedule_relationship NO_DATA and a departure - 1 error
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.NO_DATA);
    stopTimeUpdateBuilder.setStopId("1.1");
    stopTimeUpdateBuilder.setDeparture(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.clearStopTimeUpdate();
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED);
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    // StopTimeUpdate count should be 1
    assertEquals(1, feedMessageBuilder.getEntity(0).getTripUpdate().getStopTimeUpdateCount());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E042, 1);
    TestUtils.assertResults(expected, results);
    // One stop_time_update with schedule_relationship NO_DATA and an arrival - 1 error
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.NO_DATA);
    stopTimeUpdateBuilder.setStopId("1.1");
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.clearStopTimeUpdate();
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED);
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    // StopTimeUpdate count should be 1
    assertEquals(1, feedMessageBuilder.getEntity(0).getTripUpdate().getStopTimeUpdateCount());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E042, 1);
    TestUtils.assertResults(expected, results);
    clearAndInitRequiredFeedFields();
}
Also used : HashMap(java.util.HashMap) StopTimeUpdateValidator(edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.StopTimeUpdateValidator) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) GtfsRealtime(com.google.transit.realtime.GtfsRealtime) Test(org.junit.Test) FeedMessageTest(edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest)

Example 38 with ValidationRule

use of edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule in project gtfs-realtime-validator by CUTR-at-USF.

the class StopTimeUpdateValidatorTest method testE051.

/**
 * E051 - GTFS-rt stop_sequence not found in GTFS data
 */
@Test
public void testE051() {
    /**
     * bullrunner-gtfs.zip (bullRunnerGtfs) has the following in stop_times.txt:
     *
     * trip_id,arrival_time,departure_time,stop_id,stop_sequence
     * 1,07:00:00,07:00:00,222,1
     * 1,07:01:04,07:01:04,230,2
     * 1,07:01:38,07:01:38,214,3
     * 1,07:02:15,07:02:15,204,4
     * 1,07:02:56,07:02:56,102,5
     * 1,07:03:38,07:03:38,101,6
     * 1,07:04:04,07:04:04,108,7
     * 1,07:04:32,07:04:32,110,8
     * 1,07:05:38,07:05:38,166,9
     * 1,07:06:44,07:06:44,162,10
     * 1,07:07:48,07:07:48,158,11
     * 1,07:08:30,07:08:30,154,12
     * 1,07:09:20,07:09:20,150,13
     * 1,07:09:52,07:09:52,446,14
     * 1,07:11:01,07:11:01,432,15
     * 1,07:11:49,07:11:49,430,16
     * 1,07:12:34,07:12:34,426,17
     * 1,07:13:41,07:13:41,418,18
     * 1,07:14:34,07:14:34,401,19
     * 1,07:16:07,07:16:07,414,20
     * 1,07:16:53,07:16:53,330,21
     * 1,07:17:21,07:17:21,328,22
     * 1,07:17:59,07:17:59,326,23
     * 1,07:18:43,07:18:43,226,24
     * 1,07:19:43,07:19:43,222,25
     */
    StopTimeUpdateValidator stopSequenceValidator = new StopTimeUpdateValidator();
    Map<ValidationRule, Integer> expected = new HashMap<>();
    GtfsRealtime.TripUpdate.StopTimeUpdate.Builder stopTimeUpdateBuilder = GtfsRealtime.TripUpdate.StopTimeUpdate.newBuilder();
    GtfsRealtime.TripDescriptor.Builder tripDescriptorBuilder = GtfsRealtime.TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1");
    tripDescriptorBuilder.setScheduleRelationship(GtfsRealtime.TripDescriptor.ScheduleRelationship.SCHEDULED);
    // tripDescriptor is a required field in tripUpdate
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    // stop_sequence all correctly match GTFS - no errors
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    // Last stop_sequence is wrong - 1 occurrence of E051
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    // Wrong stop_sequence (should be 25)
    stopTimeUpdateBuilder.setStopSequence(26);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E051, 1);
    TestUtils.assertResults(expected, results);
    // Both stop_sequence and stop_id are included, with the last stop_sequence being wrong - 1 occurrence of E051
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    // Wrong stop_sequence (should be 25)
    stopTimeUpdateBuilder.setStopSequence(26);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E051, 1);
    TestUtils.assertResults(expected, results);
    // Both stop_sequence and stop_id are included, with the wrong stop_sequence 0 at beginning of trip - 1 occurrence of E051
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clear();
    // Wrong stop_sequence (should be 1)
    stopTimeUpdateBuilder.setStopSequence(0);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(6);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E051, 1);
    TestUtils.assertResults(expected, results);
    // Both stop_sequence and stop_id are included, with the wrong stop_sequence 250 being added in the middle of trip - 1 occurrence of E051
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setStopId("230");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setStopId("214");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setStopId("204");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setStopId("102");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    // Wrong stop_sequence (should be 6)
    stopTimeUpdateBuilder.setStopSequence(250);
    stopTimeUpdateBuilder.setStopId("101");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setStopId("162");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setStopId("154");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setStopId("222");
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E051, 1);
    TestUtils.assertResults(expected, results);
    // Only stop_sequence is included, with the wrong stop_sequence 250 being added in the middle of trip - 1 occurrence of E051
    tripUpdateBuilder.clearStopTimeUpdate();
    stopTimeUpdateBuilder.clear();
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(3);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(4);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(5);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    // Wrong stop_sequence (should be 6)
    stopTimeUpdateBuilder.setStopSequence(250);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(10);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(12);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    stopTimeUpdateBuilder.setStopSequence(25);
    stopTimeUpdateBuilder.setScheduleRelationship(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeUpdateBuilder.setArrival(GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder().setDelay(60).build());
    tripUpdateBuilder.addStopTimeUpdate(stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = stopSequenceValidator.validate(TimestampUtils.MIN_POSIX_TIME, bullRunnerGtfs, bullRunnerGtfsMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    expected.put(E051, 1);
    TestUtils.assertResults(expected, results);
    clearAndInitRequiredFeedFields();
}
Also used : HashMap(java.util.HashMap) StopTimeUpdateValidator(edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.StopTimeUpdateValidator) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) GtfsRealtime(com.google.transit.realtime.GtfsRealtime) Test(org.junit.Test) FeedMessageTest(edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest)

Example 39 with ValidationRule

use of edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule in project gtfs-realtime-validator by CUTR-at-USF.

the class GTFSDB method initializeDB.

public static void initializeDB() {
    Session session = initSessionBeginTrans();
    List<ValidationRule> rules = ValidationRules.getRules();
    try {
        for (ValidationRule rule : rules) {
            session.saveOrUpdate(rule);
        }
        commitAndCloseSession(session);
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
    _log.info("Table initialized successfully");
}
Also used : Session(org.hibernate.Session) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule)

Example 40 with ValidationRule

use of edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule in project gtfs-realtime-validator by CUTR-at-USF.

the class TimestampValidatorTest method testE025.

/**
 * E025 - stop_time_update departure time is before arrival time
 */
@Test
public void testE025() {
    TimestampValidator timestampValidator = new TimestampValidator();
    Map<ValidationRule, Integer> expected = new HashMap<>();
    GtfsRealtime.TripDescriptor.Builder tripDescriptorBuilder = GtfsRealtime.TripDescriptor.newBuilder();
    final long CURRENT_TIME_MILLIS = TimeUnit.SECONDS.toMillis(MIN_POSIX_TIME);
    /**
     * Set timestamps on objects (without StopTimeUpdates first) so no errors
     */
    feedHeaderBuilder.setTimestamp(MIN_POSIX_TIME);
    feedMessageBuilder.setHeader(feedHeaderBuilder.build());
    tripUpdateBuilder.setTimestamp(MIN_POSIX_TIME);
    tripUpdateBuilder.setTrip(tripDescriptorBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder);
    vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME);
    feedEntityBuilder.setVehicle(vehiclePositionBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = timestampValidator.validate(CURRENT_TIME_MILLIS, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    /**
     * StopTimeUpdate has departure time equal to arrival time - 0 errors
     */
    GtfsRealtime.TripUpdate.StopTimeUpdate.Builder stopTimeUpdateBuilder = GtfsRealtime.TripUpdate.StopTimeUpdate.newBuilder();
    GtfsRealtime.TripUpdate.StopTimeEvent.Builder stopTimeEventBuilder = GtfsRealtime.TripUpdate.StopTimeEvent.newBuilder();
    stopTimeUpdateBuilder.setArrival(stopTimeEventBuilder.setTime(MIN_POSIX_TIME));
    stopTimeUpdateBuilder.setDeparture(stopTimeEventBuilder.setTime(MIN_POSIX_TIME));
    tripUpdateBuilder.addStopTimeUpdate(0, stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder);
    vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME);
    feedEntityBuilder.setVehicle(vehiclePositionBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = timestampValidator.validate(CURRENT_TIME_MILLIS, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    /**
     * StopTimeUpdate has departure time greater than arrival time - 0 errors
     */
    stopTimeUpdateBuilder.setArrival(stopTimeEventBuilder.setTime(MIN_POSIX_TIME));
    stopTimeUpdateBuilder.setDeparture(stopTimeEventBuilder.setTime(MIN_POSIX_TIME + 1));
    tripUpdateBuilder.setStopTimeUpdate(0, stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder);
    vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME);
    feedEntityBuilder.setVehicle(vehiclePositionBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = timestampValidator.validate(CURRENT_TIME_MILLIS, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.clear();
    TestUtils.assertResults(expected, results);
    /**
     * StopTimeUpdate has departure time less than arrival time - 1 error
     */
    stopTimeUpdateBuilder.setArrival(stopTimeEventBuilder.setTime(MIN_POSIX_TIME + 1));
    stopTimeUpdateBuilder.setDeparture(stopTimeEventBuilder.setTime(MIN_POSIX_TIME));
    tripUpdateBuilder.setStopTimeUpdate(0, stopTimeUpdateBuilder.build());
    feedEntityBuilder.setTripUpdate(tripUpdateBuilder);
    vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME);
    feedEntityBuilder.setVehicle(vehiclePositionBuilder.build());
    feedMessageBuilder.setEntity(0, feedEntityBuilder.build());
    results = timestampValidator.validate(CURRENT_TIME_MILLIS, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null);
    expected.put(E025, 1);
    TestUtils.assertResults(expected, results);
    clearAndInitRequiredFeedFields();
}
Also used : HashMap(java.util.HashMap) TimestampValidator(edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.TimestampValidator) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) GtfsRealtime(com.google.transit.realtime.GtfsRealtime) Test(org.junit.Test) FeedMessageTest(edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest)

Aggregations

ValidationRule (edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule)65 Test (org.junit.Test)62 HashMap (java.util.HashMap)59 FeedMessageTest (edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest)58 GtfsRealtime (com.google.transit.realtime.GtfsRealtime)23 TripDescriptorValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.TripDescriptorValidator)14 StopTimeUpdateValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.StopTimeUpdateValidator)13 TimestampValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.TimestampValidator)11 VehicleValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.VehicleValidator)8 ErrorListHelperModel (edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel)6 MessageLogModel (edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel)4 OccurrenceModel (edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel)4 FrequencyTypeZeroValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.FrequencyTypeZeroValidator)3 HeaderValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.HeaderValidator)3 CrossFeedDescriptorValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.CrossFeedDescriptorValidator)2 StopValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.StopValidator)2 GtfsMetadata (edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata)1 StopLocationTypeValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.gtfs.StopLocationTypeValidator)1 FrequencyTypeOneValidator (edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.FrequencyTypeOneValidator)1 Field (java.lang.reflect.Field)1