Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kohl committed Dec 18, 2024
1 parent 5b7229d commit d6e3874
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 9 deletions.
36 changes: 36 additions & 0 deletions src/test/java/org/matsim/pt2matsim/gtfs/GtfsConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.matsim.core.utils.geometry.transformations.TransformationFactory;
import org.matsim.pt.transitSchedule.api.*;
import org.matsim.pt.utils.TransitScheduleValidator;
import org.matsim.pt2matsim.gtfs.lib.GtfsDefinitions.RouteType;
import org.matsim.pt2matsim.tools.ScheduleTools;
import org.matsim.pt2matsim.tools.ScheduleToolsTest;

Expand Down Expand Up @@ -161,6 +162,41 @@ void testTransfers() {

Assertions.assertEquals(expectedTransferTimes, actualTransferTime);
}

@Test
void testAdditionalLineInfo() {
Assertions.assertEquals(3, gtfsConverter.getAdditionalLineInfo().size());

AdditionalTransitLineInfo lineA = gtfsConverter.getAdditionalLineInfo().get(Id.create("lineA", TransitLine.class));
Assertions.assertNotNull(lineA);
Assertions.assertEquals("lineA", lineA.getId());
Assertions.assertEquals("Line A", lineA.getShortName());
Assertions.assertEquals("Bus Line A", lineA.getLongName());
Assertions.assertEquals(RouteType.BUS, lineA.getRouteType());
Assertions.assertEquals("S42", lineA.getAgencyId());
Assertions.assertEquals("Service 42", lineA.getAgencyName());
Assertions.assertEquals("htpps://google.com", lineA.getAgencyURL());

AdditionalTransitLineInfo lineB = gtfsConverter.getAdditionalLineInfo().get(Id.create("lineB", TransitLine.class));
Assertions.assertNotNull(lineB);
Assertions.assertEquals("lineB", lineB.getId());
Assertions.assertEquals("Line B", lineB.getShortName());
Assertions.assertEquals("Tram Line B", lineB.getLongName());
Assertions.assertEquals(RouteType.TRAM, lineB.getRouteType());
Assertions.assertEquals("P2M", lineB.getAgencyId());
Assertions.assertEquals("pt2matsim", lineB.getAgencyName());
Assertions.assertEquals("https://github.com/matsim-org/pt2matsim", lineB.getAgencyURL());

AdditionalTransitLineInfo lineC = gtfsConverter.getAdditionalLineInfo().get(Id.create("lineC", TransitLine.class));
Assertions.assertNotNull(lineC);
Assertions.assertEquals("lineC", lineC.getId());
Assertions.assertEquals("Line C", lineC.getShortName());
Assertions.assertEquals("Something else", lineC.getLongName());
Assertions.assertEquals(RouteType.OTHER, lineC.getRouteType());
Assertions.assertEquals("P2M", lineC.getAgencyId());
Assertions.assertEquals("pt2matsim", lineC.getAgencyName());
Assertions.assertEquals("https://github.com/matsim-org/pt2matsim", lineC.getAgencyURL());
}

private String getTransferTimeTestString(MinimalTransferTimes.MinimalTransferTimesIterator iterator) {
return iterator.getFromStopId().toString() + "-" + iterator.getToStopId().toString() + "-" + iterator.getSeconds();
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/matsim/pt2matsim/gtfs/GtfsFeedImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ void statistics() {
Assertions.assertEquals(3, feed.getShapes().size());
Assertions.assertEquals(6, feed.getTrips().size());
Assertions.assertEquals(6, feed.getTransfers().size());
Assertions.assertEquals(2, feed.getAgencies().size());
}

@Test
void agencyAssociation() {
feed.getRoutes().values().forEach(route -> Assertions.assertNotNull(route.getAgency(), "no agency in route " + route.getId()));
}

@Test
Expand Down
3 changes: 2 additions & 1 deletion test/gtfs-feed-cal/agency.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
agency_id,agency_name,agency_url,agency_timezone
P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich
P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich
S42,Service 42,htpps://google.com,Europe/Berlin
7 changes: 4 additions & 3 deletions test/gtfs-feed-cal/routes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
route_id,route_short_name,route_long_name,route_type
lineA,Line A,Bus Line A,3
lineB,Line B,Tram Line B,0
route_id,route_short_name,route_long_name,route_type,agency_id,
lineA,Line A,Bus Line A,3,S42
lineB,Line B,Tram Line B,0,P2M
lineC,Line C,Something else,907,P2M
3 changes: 2 additions & 1 deletion test/gtfs-feed/agency.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
agency_id,agency_name,agency_url,agency_timezone
P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich
P2M,pt2matsim,https://github.com/matsim-org/pt2matsim,Europe/Zurich
S42,Service 42,htpps://google.com,Europe/Berlin
8 changes: 4 additions & 4 deletions test/gtfs-feed/routes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
route_id,route_short_name,route_long_name,route_type
lineA,Line A,Bus Line A,3
lineB,Line B,Tram Line B,0
lineC,Line C,Something else,907
route_id,route_short_name,route_long_name,route_type,agency_id,
lineA,Line A,Bus Line A,3,S42
lineB,Line B,Tram Line B,0,P2M
lineC,Line C,Something else,907,P2M

0 comments on commit d6e3874

Please sign in to comment.