Skip to content

Commit

Permalink
fix: Fix typo in TimeframeOverlapNotice class name (#1569)
Browse files Browse the repository at this point in the history
* Fix typo in TimeframeOverlapNotice name + add test to prevent future typos.
  • Loading branch information
bdferris-v2 authored Sep 13, 2023
1 parent 95f0c9a commit 96a1b4d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void validate(NoticeContainer noticeContainer) {
GtfsTimeframe curr = timeframes.get(i);
if (curr.startTime().isBefore(prev.endTime())) {
noticeContainer.addValidationNotice(
new TimeframeOverlapNoice(
new TimeframeOverlapNotice(
prev.csvRowNumber(),
prev.endTime(),
curr.csvRowNumber(),
Expand Down Expand Up @@ -82,7 +82,7 @@ static TimeframeKey create(GtfsTimeframe timeframe) {
* < X.end_time`.
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsFrequencySchema.class))
static class TimeframeOverlapNoice extends ValidationNotice {
static class TimeframeOverlapNotice extends ValidationNotice {

/** The row number of the first timeframe entry. */
private final long prevCsvRowNumber;
Expand All @@ -102,7 +102,7 @@ static class TimeframeOverlapNoice extends ValidationNotice {
/** The service id associated with the two entries. */
private final String serviceId;

TimeframeOverlapNoice(
TimeframeOverlapNotice(
long prevCsvRowNumber,
GtfsTime prevEndTime,
long currCsvRowNumber,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.mobilitydata.gtfsvalidator.validator;

import static com.google.common.truth.Truth.assertWithMessage;

import java.util.List;
import java.util.stream.Collectors;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mobilitydata.gtfsvalidator.notice.Notice;
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;

@RunWith(JUnit4.class)
public class NoticeNameTest {

@Test
public void testAllValidationNoticeClassesEndWithNotice() {
List<Class<Notice>> noticesWithoutNoticeSuffix =
ClassGraphDiscovery.discoverNoticeSubclasses(ClassGraphDiscovery.DEFAULT_NOTICE_PACKAGES)
.stream()
.filter(c -> ValidationNotice.class.isAssignableFrom(c))
.filter(c -> !c.getSimpleName().endsWith("Notice"))
.collect(Collectors.toList());
assertWithMessage(
"All GtfsValidationNotice subclasses must have \"Notice\" as their class name suffix, but the following classes do not:")
.that(noticesWithoutNoticeSuffix)
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.mobilitydata.gtfsvalidator.table.GtfsTimeframe;
import org.mobilitydata.gtfsvalidator.table.GtfsTimeframeTableContainer;
import org.mobilitydata.gtfsvalidator.type.GtfsTime;
import org.mobilitydata.gtfsvalidator.validator.TimeframeOverlapValidator.TimeframeOverlapNoice;
import org.mobilitydata.gtfsvalidator.validator.TimeframeOverlapValidator.TimeframeOverlapNotice;

@RunWith(JUnit4.class)
public class TimeframeOverlapValidatorTest {
Expand Down Expand Up @@ -92,7 +92,7 @@ public void testOverlap() {
.setCsvRowNumber(3)
.build()))
.containsExactly(
new TimeframeOverlapNoice(
new TimeframeOverlapNotice(
2,
GtfsTime.fromString("09:00:00"),
3,
Expand Down

0 comments on commit 96a1b4d

Please sign in to comment.