use of org.onebusaway.admin.model.ServiceDateRange in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImplTest method testGetServiceDateRange.
@Test
public void testGetServiceDateRange() throws Exception {
BundleValidationServiceImpl impl = new BundleValidationServiceImpl();
// load zip file
InputStream input = this.getClass().getResourceAsStream("google_transit_staten_island.zip");
assertNotNull(input);
List<ServiceDateRange> ranges = impl.getServiceDateRanges(input);
assertNotNull(ranges);
assertTrue(ranges.size() == 4);
ServiceDateRange sdr0 = ranges.get(0);
assertEquals("MTA NYCT", sdr0.getAgencyId());
assertEquals(2012, sdr0.getStartDate().getYear());
assertEquals(4, sdr0.getStartDate().getMonth());
assertEquals(8, sdr0.getStartDate().getDay());
assertEquals(2012, sdr0.getEndDate().getYear());
assertEquals(7, sdr0.getEndDate().getMonth());
assertEquals(7, sdr0.getEndDate().getDay());
}
use of org.onebusaway.admin.model.ServiceDateRange in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImplTest method testCommonServiceDateRangeAcrossGTFS.
@Test
public void testCommonServiceDateRangeAcrossGTFS() throws Exception {
BundleValidationServiceImpl impl = new BundleValidationServiceImpl();
// load zip file
ArrayList<InputStream> inputs = new ArrayList<InputStream>();
inputs.add(this.getClass().getResourceAsStream("google_transit_staten_island.zip"));
inputs.add(this.getClass().getResourceAsStream("google_transit_manhattan.zip"));
Map<String, List<ServiceDateRange>> map = impl.getServiceDateRangesAcrossAllGtfs(inputs);
ServiceDateRange sdr0 = map.get("MTA NYCT").get(0);
assertEquals(2012, sdr0.getStartDate().getYear());
assertEquals(4, sdr0.getStartDate().getMonth());
assertEquals(8, sdr0.getStartDate().getDay());
assertEquals(2012, sdr0.getEndDate().getYear());
assertEquals(7, sdr0.getEndDate().getMonth());
assertEquals(7, sdr0.getEndDate().getDay());
}
use of org.onebusaway.admin.model.ServiceDateRange in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImplTest method testCommonServiceDateRange.
@Test
public void testCommonServiceDateRange() throws Exception {
BundleValidationServiceImpl impl = new BundleValidationServiceImpl();
// load zip file
InputStream input = this.getClass().getResourceAsStream("google_transit_staten_island.zip");
assertNotNull(input);
List<ServiceDateRange> ranges = impl.getServiceDateRanges(input);
Map<String, List<ServiceDateRange>> map = impl.getServiceDateRangesByAgencyId(ranges);
ServiceDateRange sdr0 = map.get("MTA NYCT").get(0);
assertEquals("MTA NYCT", sdr0.getAgencyId());
assertEquals(2012, sdr0.getStartDate().getYear());
assertEquals(4, sdr0.getStartDate().getMonth());
assertEquals(8, sdr0.getStartDate().getDay());
assertEquals(2012, sdr0.getEndDate().getYear());
assertEquals(7, sdr0.getEndDate().getMonth());
assertEquals(7, sdr0.getEndDate().getDay());
}
use of org.onebusaway.admin.model.ServiceDateRange in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImpl method getServiceDateRangesByAgencyId.
@Override
public /**
* collect all service date ranges in the list, and return
* map of key=agencyId, value=ServiceDateRange
*/
Map<String, List<ServiceDateRange>> getServiceDateRangesByAgencyId(List<ServiceDateRange> ranges) {
HashMap<String, List<ServiceDateRange>> map = new HashMap<String, List<ServiceDateRange>>();
for (ServiceDateRange sd : ranges) {
List<ServiceDateRange> list = map.get(sd.getAgencyId());
if (list == null) {
list = new ArrayList<ServiceDateRange>();
}
list.add(sd);
map.put(sd.getAgencyId(), list);
}
return map;
}
use of org.onebusaway.admin.model.ServiceDateRange in project onebusaway-application-modules by camsys.
the class BundleValidationServiceImpl method convertToServiceDateRange.
private List<ServiceDateRange> convertToServiceDateRange(String agencyId, String calendarFile) {
String[] entries = calendarFile.split("\n");
List<ServiceDateRange> ranges = new ArrayList<ServiceDateRange>();
int line = 0;
for (String entry : entries) {
// skip header
if (line != 0) {
String[] columns = entry.split(",");
if (columns.length > 9) {
ranges.add(new ServiceDateRange(agencyId, parseDate(columns[8]), parseDate(columns[9])));
}
}
line++;
}
return ranges;
}
Aggregations