Source:
public void canNormalizePatternStopTimes() throws IOException, SQLException, InvalidNamespaceException { final Table tripsTable = Table.TRIPS; int initialTravelTime = 60; int startTime = 6 * 60 * 60; String patternId = "123456"; PatternStopDTO[] patternStops = new PatternStopDTO[]{ new PatternStopDTO(patternId, firstStopId, 0), new PatternStopDTO(patternId, lastStopId, 1) }; patternStops[1].default_travel_time = initialTravelTime; PatternDTO pattern = createRouteAndPattern(UUID.randomUUID().toString(), patternId, "Pattern A", null, new ShapePointDTO[]{}, patternStops, 0); TripDTO tripInput = constructTimetableTrip(pattern.pattern_id, pattern.route_id, startTime, initialTravelTime); JdbcTableWriter createTripWriter = createTestTableWriter(tripsTable); String createTripOutput = createTripWriter.create(mapper.writeValueAsString(tripInput), true); LOG.info(createTripOutput); TripDTO createdTrip = mapper.readValue(createTripOutput, TripDTO.class); JdbcTableWriter patternUpdater = createTestTableWriter(Table.PATTERNS); int updatedTravelTime = 3600; pattern.pattern_stops[1].default_travel_time = updatedTravelTime; String updatedPatternOutput = patternUpdater.update(pattern.id, mapper.writeValueAsString(pattern), true); LOG.info("Updated pattern output: {}", updatedPatternOutput); JdbcTableWriter updateTripWriter = createTestTableWriter(tripsTable); updateTripWriter.normalizeStopTimesForPattern(pattern.id, 0); JDBCTableReader<StopTime> stopTimesTable = new JDBCTableReader(Table.STOP_TIMES, testDataSource, testNamespace + ".", EntityPopulator.STOP_TIME); int index = 0; for (StopTime stopTime : stopTimesTable.getOrdered(createdTrip.trip_id)) { LOG.info("stop times i={} arrival={} departure={}", index, stopTime.arrival_time, stopTime.departure_time); assertThat(stopTime.arrival_time, equalTo(startTime + index * updatedTravelTime)); index++; } assertThat(index, equalTo(patternStops.length)); }

Target:
public void canNormalizePatternStopTimes() throws IOException, SQLException, InvalidNamespaceException { final Table tripsTable = Table.TRIPS; int initialTravelTime = 60; int startTime = 6 * 60 * 60; String patternId = "123456"; PatternStopDTO[] patternStops = new PatternStopDTO[]{ new PatternStopDTO(patternId, firstStopId, 0), new PatternStopDTO(patternId, lastStopId, 1) }; patternStops[1].default_travel_time = initialTravelTime; PatternDTO pattern = createRouteAndPattern(newUUID(), patternId, "Pattern A", null, new ShapePointDTO[]{}, patternStops, 0); TripDTO tripInput = constructTimetableTrip(pattern.pattern_id, pattern.route_id, startTime, initialTravelTime); JdbcTableWriter createTripWriter = createTestTableWriter(tripsTable); String createTripOutput = createTripWriter.create(mapper.writeValueAsString(tripInput), true); LOG.info(createTripOutput); TripDTO createdTrip = mapper.readValue(createTripOutput, TripDTO.class); JdbcTableWriter patternUpdater = createTestTableWriter(Table.PATTERNS); int updatedTravelTime = 3600; pattern.pattern_stops[1].default_travel_time = updatedTravelTime; String updatedPatternOutput = patternUpdater.update(pattern.id, mapper.writeValueAsString(pattern), true); LOG.info("Updated pattern output: {}", updatedPatternOutput); JdbcTableWriter updateTripWriter = createTestTableWriter(tripsTable); updateTripWriter.normalizeStopTimesForPattern(pattern.id, 0); JDBCTableReader<StopTime> stopTimesTable = new JDBCTableReader(Table.STOP_TIMES, testDataSource, testNamespace + ".", EntityPopulator.STOP_TIME); int index = 0; for (StopTime stopTime : stopTimesTable.getOrdered(createdTrip.trip_id)) { LOG.info("stop times i={} arrival={} departure={}", index, stopTime.arrival_time, stopTime.departure_time); assertThat(stopTime.arrival_time, equalTo(startTime + index * updatedTravelTime)); index++; } assertThat(index, equalTo(patternStops.length)); }