AggregateLineStopProcessor extends AbstractGtfsDataProcessor<LineStop, LineStop> implements InitializingBean { @Override public LineStop process(LineStop item) throws Exception { LineStop result = passThrough(item, this::merge); if (result == null) { result = passThrough(item, this::aggregate); } LOGGER.debug("result", result); return result; }  @Override void afterPropertiesSet(); @Override LineStop process(LineStop item); void setTrainLineDao(TrainLineDao trainLineDao); void setLineStopDao(LineStopDao lineStopDao); void setStationDao(StationDao stationDao);  }
@Test public void testProcessAggregate() throws Exception { Station station = new Station("Liège-Guillemins"); TrainLine trainLine = new TrainLine.Builder(1L).build(false); LineStop expected = new LineStop.Builder() .trainLine(trainLine) .station(station) .date(LocalDate.now()) .addNext(new LineStop.Builder() .trainLine(trainLine) .station(new Station("Bruxelles-central")) .date(LocalDate.now()) ) .build(false); expect(lineStopDao.findByTrainLineAndDateAndStation(anyObject(), anyObject(), anyObject())).andReturn(null); expect(stationDao.findByEnglishName(anyString())).andReturn(station); expect(trainLineDao.findByRouteId(anyLong())).andReturn(trainLine); replayAll(); assertNotNull(processor.process(expected)); }
@Test public void testProcessMerge() throws Exception { Station station = new Station("Liège-Guillemins"); TrainLine trainLine = new TrainLine.Builder(1L).build(false); LineStop expected = new LineStop.Builder() .trainLine(trainLine) .station(station) .date(LocalDate.now()) .addNext(new LineStop.Builder() .trainLine(trainLine) .station(new Station("Bruxelles-central")) .date(LocalDate.now()) ) .build(false); expect(lineStopDao.findByTrainLineAndDateAndStation(anyObject(), anyObject(), anyObject())) .andReturn(expected); replayAll(); assertNotNull(processor.process(expected)); }