use of org.onebusaway.gtfs.model.FeedInfo in project onebusaway-gtfs-modules by OneBusAway.
the class TranslationServiceImplTest method testTranslations.
@Test
public void testTranslations() throws IOException {
String agencyId = "agency";
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsTestData.readGtfs(dao, GtfsTestData.getTestAgencyGtfs(), agencyId);
TranslationServiceImpl ts = new TranslationServiceImpl();
ts.setData(TranslationServiceDataFactoryImpl.createData(dao));
Agency agency = dao.getAgencyForId(agencyId);
assertEquals("Fake Agency Spanish", ts.getTranslatedEntity("es", Agency.class, agency).getName());
assertEquals("Fake Agency French", ts.getTranslatedEntity("fr", Agency.class, agency).getName());
Stop stop = dao.getStopForId(aid("A"));
assertEquals("A Spanish", ts.getTranslatedEntity("es", Stop.class, stop).getName());
assertEquals("A French", ts.getTranslatedEntity("fr", Stop.class, stop).getName());
Route route = dao.getRouteForId(aid("3"));
assertEquals("3 Spanish", ts.getTranslatedEntity("es", Route.class, route).getLongName());
assertEquals("3 French", ts.getTranslatedEntity("fr", Route.class, route).getLongName());
Trip trip3 = dao.getTripForId(aid("3.1"));
assertEquals("headsign Spanish", ts.getTranslatedEntity("es", Trip.class, trip3).getTripHeadsign());
assertEquals("headsign French", ts.getTranslatedEntity("fr", Trip.class, trip3).getTripHeadsign());
Trip trip4 = dao.getTripForId(aid("4.3"));
List<StopTime> stopTimes = dao.getStopTimesForTrip(trip4);
StopTime st1 = stopTimes.get(0);
StopTime st2 = stopTimes.get(1);
assertEquals("to G Spanish", ts.getTranslatedEntity("es", StopTime.class, st1).getStopHeadsign());
assertEquals("to H Spanish", ts.getTranslatedEntity("es", StopTime.class, st2).getStopHeadsign());
assertEquals("to G French", ts.getTranslatedEntity("fr", StopTime.class, st1).getStopHeadsign());
assertEquals("to H French", ts.getTranslatedEntity("fr", StopTime.class, st2).getStopHeadsign());
FeedInfo feedInfo = dao.getAllFeedInfos().iterator().next();
assertEquals("Fake Feed Publisher Spanish", ts.getTranslatedEntity("es", FeedInfo.class, feedInfo).getPublisherName());
assertEquals("http://fake.example.es", ts.getTranslatedEntity("es", FeedInfo.class, feedInfo).getPublisherUrl());
assertEquals("Fake Feed Publisher French", ts.getTranslatedEntity("fr", FeedInfo.class, feedInfo).getPublisherName());
assertEquals("http://fake.example.fr", ts.getTranslatedEntity("fr", FeedInfo.class, feedInfo).getPublisherUrl());
// Check default translations
assertEquals("Fake Agency", ts.getTranslatedEntity("en", Agency.class, agency).getName());
assertEquals("A", ts.getTranslatedEntity("en", Stop.class, stop).getName());
assertEquals("3", ts.getTranslatedEntity("en", Route.class, route).getLongName());
assertEquals("headsign", ts.getTranslatedEntity("en", Trip.class, trip3).getTripHeadsign());
assertEquals("to G", ts.getTranslatedEntity("en", StopTime.class, st1).getStopHeadsign());
assertEquals("to H", ts.getTranslatedEntity("en", StopTime.class, st2).getStopHeadsign());
assertEquals("Fake Feed Publisher", ts.getTranslatedEntity("en", FeedInfo.class, feedInfo).getPublisherName());
assertEquals("http://fake.example.com", ts.getTranslatedEntity("en", FeedInfo.class, feedInfo).getPublisherUrl());
}
Aggregations