FeedServiceImpl implements FeedService { @Override public List<AlertModel> readAlerts(FeedMessage alerts, GtfsRealtimeEntitySource entitySource) { List<AlertModel> updates = GtfsRealtimeConversionLibrary.readAlerts(alerts); for (AlertModel alert : updates) { for (EntitySelectorModel esm : alert.getEntitySelectors()) { String agencyId = getAgencyId(entitySource); if (StringUtils.isEmpty(agencyId) && esm.getAgencyId() != null && esm.getAgencyId().length() > 0) { agencyId = esm.getAgencyId(); } addAgencyIdToTripId(esm, agencyId, entitySource); addAgencyIdToRouteId(esm, agencyId, entitySource); addAgencyIdToStopId(esm, agencyId, entitySource); } _persistor.persist(alert); } return updates; }  @Autowired void setGtfsPersistor(GtfsPersistor persistor); @Override List<TripUpdateModel> readTripUpdates(FeedMessage tripUpdates,
      GtfsRealtimeEntitySource entitySource); @Override List<VehiclePositionModel> readVehiclePositions(
      FeedMessage vehiclePositions, GtfsRealtimeEntitySource entitySource); @Override List<AlertModel> readAlerts(FeedMessage alerts,
      GtfsRealtimeEntitySource entitySource);  }
@Test @Transactional public void testReadAlerts() { FeedEntity alertEntityA = createAlert("alertA", TEST_1, DESC_1, CAUSE_1, EFFECT_1, URL_1, TIME_START_1, TIME_END_1, AGENCY_1, ROUTE_1, STOP_1); FeedEntity alertEntityB = createAlert("alertB", TEST_2, DESC_2, CAUSE_2, EFFECT_2, URL_2, TIME_START_2, TIME_END_2, AGENCY_2, ROUTE_2, STOP_2); FeedEntity alertEntityC = createAlert("alertC", TEST_3, DESC_3, CAUSE_3, EFFECT_3, URL_3, TIME_START_3, TIME_END_3, AGENCY_3, ROUTE_3, STOP_3); FeedMessage.Builder alerts = createFeed(); alerts.addEntity(alertEntityA); alerts.addEntity(alertEntityB); alerts.addEntity(alertEntityC); FeedMessage alert = alerts.build(); _feedService.readAlerts(alert, _entitySource); Collection<AlertModel> alertsFromDB = null; try { TimeUnit.SECONDS.sleep(15); } catch (Exception ignoredEx) { } try { Query query = getSession().createQuery("from AlertModel"); alertsFromDB = query.list(); } catch (Exception ex) { ex.getMessage(); _log.info("find failed: " + ex.getMessage()); } assertNotNull("database query failed!", alertsFromDB); _log.info("results size: " + alertsFromDB.size()); assertEquals(3, alertsFromDB.size()); for (AlertModel alertFromDB : alertsFromDB) { String header = alertFromDB.getHeaderText(); String desc = alertFromDB.getDescriptionText(); String cause = alertFromDB.getCause(); String effect = alertFromDB.getEffect(); String url = alertFromDB.getUrl(); long timeStart = 0L; long timeEnd = 0L; List<TimeRangeModel> timeRanges = alertFromDB.getTimeRanges(); for (TimeRangeModel tr : timeRanges) { timeStart = tr.getStart(); timeEnd = tr.getEnd(); } String agency = ""; String route = ""; String stop = ""; List<EntitySelectorModel> entitySelectors = alertFromDB.getEntitySelectors(); for (EntitySelectorModel es : entitySelectors) { agency = es.getAgencyId(); route = es.getRouteId(); stop = es.getStopId(); } if (header.equals(TEST_1)) { assertEquals(TEST_1, header); assertEquals(DESC_1, desc); assertEquals(CAUSE_1.toString(), cause); assertEquals(EFFECT_1.toString(), effect); assertEquals(URL_1.toString(), url); assertEquals(TIME_START_1, timeStart); assertEquals(TIME_END_1, timeEnd); assertEquals(AGENCY_1, agency); assertEquals(ROUTE_1, route); assertEquals(STOP_1, stop); } else if (header.equals(TEST_2)) { assertEquals(TEST_2, header); assertEquals(DESC_2, desc); assertEquals(CAUSE_2.toString(), cause); assertEquals(EFFECT_2.toString(), effect); assertEquals(URL_2.toString(), url); assertEquals(TIME_START_2, timeStart); assertEquals(TIME_END_2, timeEnd); assertEquals(AGENCY_2, agency); assertEquals(AGENCY_2 + "_" + ROUTE_2, route); assertEquals(STOP_2, stop); } else if (header.equals(TEST_3)) { assertEquals(TEST_3, header); assertEquals(DESC_3, desc); assertEquals(CAUSE_3.toString(), cause); assertEquals(EFFECT_3.toString(), effect); assertEquals(URL_3.toString(), url); assertEquals(TIME_START_3, timeStart); assertEquals(TIME_END_3, timeEnd); assertEquals(AGENCY_3, agency); assertEquals(ROUTE_3, route); assertEquals(AGENCY_3 + "_" + STOP_3, stop); } } }