Skip to content

Commit

Permalink
Merge pull request #311 from conveyal/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
landonreed authored Apr 9, 2021
2 parents f57cc3b + 8d0a19f commit d9418bb
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 195 deletions.
21 changes: 13 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.conveyal</groupId>
<artifactId>gtfs-lib</artifactId>
<version>6.2.2</version>
<version>6.2.3-SNAPSHOT</version>
<packaging>jar</packaging>

<licenses>
Expand Down Expand Up @@ -197,6 +197,11 @@
</execution>
</executions>
</plugin>
<!-- maven-surefire-plugin is needed to run unit tests. -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

Expand All @@ -222,11 +227,11 @@
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>
<!-- JUnit is a Java testing framework. -->
<!-- Used for unit testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<!-- Parses command line arguments to main methods. -->
Expand All @@ -237,9 +242,9 @@
</dependency>
<!-- This package allows you to run tests on code that call System.exit() -->
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.16.0</version>
<groupId>com.ginsberg</groupId>
<artifactId>junit5-system-exit</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/conveyal/gtfs/error/NewGTFSErrorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import com.conveyal.gtfs.validator.model.Priority;

/**
* This enum defines the GTFS error types that can be encountered when validating GTFS table data. Each error type has a
* severity level and related error message.
*/
public enum NewGTFSErrorType {
// Standard errors.
BOOLEAN_FORMAT(Priority.MEDIUM, "A GTFS boolean field must contain the value 1 or 0."),
Expand Down Expand Up @@ -41,16 +45,16 @@ public enum NewGTFSErrorType {
ROUTE_LONG_NAME_CONTAINS_SHORT_NAME(Priority.LOW, "The long name of a route should complement the short name, not include it."),
ROUTE_SHORT_AND_LONG_NAME_MISSING(Priority.MEDIUM, "A route has neither a long nor a short name."),
ROUTE_SHORT_NAME_TOO_LONG(Priority.MEDIUM, "The short name of a route is too long for display in standard GTFS consumer applications."),
ROUTE_UNUSED(Priority.HIGH, "This route is defined but has no trips."),
ROUTE_UNUSED(Priority.MEDIUM, "This route is defined but has no trips."),
SERVICE_NEVER_ACTIVE(Priority.MEDIUM, "A service code was defined, but is never active on any date."),
SERVICE_UNUSED(Priority.MEDIUM, "A service code was defined, but is never referenced by any trips."),
SERVICE_WITHOUT_DAYS_OF_WEEK(Priority.MEDIUM, "A service defined in calendar.txt should be active on at least one day of the week. Otherwise, it should be omitted from this file."),
SHAPE_DIST_TRAVELED_NOT_INCREASING(Priority.MEDIUM, "Shape distance traveled must increase with stop times."),
SHAPE_MISSING_COORDINATE(Priority.MEDIUM, "???"),
SHAPE_REVERSED(Priority.MEDIUM, "A shape appears to be intended for vehicles running the opposite direction on the route."),
STOP_DESCRIPTION_SAME_AS_NAME(Priority.LOW, "The description of a stop is identical to its name, so does not add any information."),
STOP_GEOGRAPHIC_OUTLIER(Priority.HIGH, "This stop is located very far from the middle 90% of stops in this feed."),
STOP_LOW_POPULATION_DENSITY(Priority.HIGH, "A stop is located in a geographic area with very low human population density."),
STOP_GEOGRAPHIC_OUTLIER(Priority.MEDIUM, "This stop is located very far from the middle 90% of stops in this feed."),
STOP_LOW_POPULATION_DENSITY(Priority.MEDIUM, "A stop is located in a geographic area with very low human population density."),
STOP_NAME_MISSING(Priority.MEDIUM, "A stop does not have a name."),
STOP_TIME_UNUSED(Priority.LOW, "This stop time allows neither pickup nor drop off and is not a timepoint, so it serves no purpose and should be removed from trip."),
STOP_UNUSED(Priority.MEDIUM, "This stop is not referenced by any trips."),
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/com/conveyal/gtfs/GTFSFeedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import com.csvreader.CsvReader;
import org.apache.commons.io.input.BOMInputStream;
import org.hamcrest.comparator.ComparatorMatcherBuilder;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.time.LocalDate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

Expand Down Expand Up @@ -51,7 +50,7 @@ public DataExpectation(String columnName, String expectedValue) {
}
}

@BeforeClass
@BeforeAll
public static void setUpClass() {
//executed only once, before the first test
simpleGtfsZipFileName = null;
Expand Down
21 changes: 8 additions & 13 deletions src/test/java/com/conveyal/gtfs/GTFSMainTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.conveyal.gtfs;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -14,18 +13,14 @@
import static org.hamcrest.Matchers.containsString;

/**
* A test suite for the GTFSMain class
* A test suite for the GTFSMain class.
*/
public class GTFSMainTest {
private static String simpleGtfsZipFileName;
private static String badGtfsZipFileName;
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();

// this is used so that it is possible to test code that calls System.exit()
@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

@BeforeClass
@BeforeAll
public static void setUpClass() {
//executed only once, before the first test
simpleGtfsZipFileName = null;
Expand All @@ -38,7 +33,7 @@ public static void setUpClass() {
}

// setup a stream to capture the output from the program
@Before
@BeforeEach
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
}
Expand All @@ -61,8 +56,8 @@ public void canPrintHelp() throws Exception {
* @throws Exception
*/
@Test
@ExpectSystemExitWithStatus(1)
public void exitsIfNoArgumentsProvided() throws Exception {
exit.expectSystemExitWithStatus(1);
String[] args = {};
GTFSMain.main(args);
assertThat(outContent.toString(), containsString("usage: java"));
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/com/conveyal/gtfs/GTFSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.apache.commons.io.input.BOMInputStream;
import org.hamcrest.Matcher;
import org.hamcrest.comparator.ComparatorMatcherBuilder;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -44,9 +44,10 @@
import static com.conveyal.gtfs.graphql.GTFSGraphQLTest.testDBName;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;


/**
* A test suite for the {@link GTFS} Class.
Expand All @@ -57,7 +58,7 @@ public class GTFSTest {
private static final Logger LOG = LoggerFactory.getLogger(GTFSTest.class);

// setup a stream to capture the output from the program
@Before
@BeforeEach
public void setUpStreams() {
System.setOut(new PrintStream(outContent));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/conveyal/gtfs/GeometriesTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.conveyal.gtfs;

import org.junit.jupiter.api.Test;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.junit.Test;

import static com.conveyal.gtfs.Geometries.geometryFactory;
import static com.conveyal.gtfs.Geometries.getNetherlandsWithoutTexel;
Expand Down
Loading

0 comments on commit d9418bb

Please sign in to comment.