From 02e7713df5dcc199f0b1b8042df553548c9de713 Mon Sep 17 00:00:00 2001 From: Jingsi Lu Date: Thu, 29 Aug 2024 15:54:27 -0400 Subject: [PATCH] renamed validator and notice --- ....java => BidirectionalExitGateValidator.java} | 16 ++++++++-------- ...a => BidirectionalExitGateValidatorTest.java} | 16 ++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) rename main/src/main/java/org/mobilitydata/gtfsvalidator/validator/{PathwayBidirectionalExitGatesValidator.java => BidirectionalExitGateValidator.java} (70%) rename main/src/test/java/org/mobilitydata/gtfsvalidator/validator/{PathwayBidirectionalExitGatesValidatorTest.java => BidirectionalExitGateValidatorTest.java} (72%) diff --git a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidator.java b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidator.java similarity index 70% rename from main/src/main/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidator.java rename to main/src/main/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidator.java index 7177676236..7fb3b3e2c2 100644 --- a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidator.java +++ b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidator.java @@ -17,12 +17,12 @@ * */ @GtfsValidator -public class PathwayBidirectionalExitGatesValidator extends SingleEntityValidator { +public class BidirectionalExitGateValidator extends SingleEntityValidator { @Override public void validate(GtfsPathway entity, NoticeContainer noticeContainer) { if (entity.pathwayMode().getNumber() == 7 && entity.isBidirectional().getNumber() == 1) { - noticeContainer.addValidationNotice(new PathwayBidirectionalExitGatesNotice(entity)); + noticeContainer.addValidationNotice(new BidirectionalExitGatesNotice(entity)); } } @@ -32,18 +32,18 @@ public void validate(GtfsPathway entity, NoticeContainer noticeContainer) { *

Exit gates (pathway_mode=7) must not be bidirectional. */ @GtfsValidationNotice(severity = ERROR, files = @FileRefs({GtfsPathwaySchema.class})) - static class PathwayBidirectionalExitGatesNotice extends ValidationNotice { + static class BidirectionalExitGatesNotice extends ValidationNotice { /** The row number of the validated record. */ private final int csvRowNumber; /** The pathway mode. */ - private final GtfsPathwayMode pathwayMode; + private final int pathwayMode; /** Whether the pathway is bidirectional. */ - private final GtfsPathwayIsBidirectional isBidirectional; + private final int isBidirectional; - PathwayBidirectionalExitGatesNotice(GtfsPathway pathway) { + BidirectionalExitGatesNotice(GtfsPathway pathway) { this.csvRowNumber = pathway.csvRowNumber(); - this.pathwayMode = pathway.pathwayMode(); - this.isBidirectional = pathway.isBidirectional(); + this.pathwayMode = pathway.pathwayMode().getNumber(); + this.isBidirectional = pathway.isBidirectional().getNumber(); } } } diff --git a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidatorTest.java b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidatorTest.java similarity index 72% rename from main/src/test/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidatorTest.java rename to main/src/test/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidatorTest.java index eabd101638..264a73bb0b 100644 --- a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/PathwayBidirectionalExitGatesValidatorTest.java +++ b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/BidirectionalExitGateValidatorTest.java @@ -4,18 +4,14 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mobilitydata.gtfsvalidator.notice.NoticeContainer; -import org.mobilitydata.gtfsvalidator.notice.ValidationNotice; import org.mobilitydata.gtfsvalidator.table.GtfsPathway; import org.mobilitydata.gtfsvalidator.table.GtfsPathwayIsBidirectional; -import org.mobilitydata.gtfsvalidator.table.GtfsPathwayMode; -import java.util.List; - import static com.google.common.truth.Truth.assertThat; @RunWith(JUnit4.class) -public class PathwayBidirectionalExitGatesValidatorTest { +public class BidirectionalExitGateValidatorTest { public static GtfsPathway createPathway(int csvRowNumber, Integer pathwayMode, GtfsPathwayIsBidirectional gtfsPathwayIsBidirectional) { return new GtfsPathway.Builder() .setCsvRowNumber(csvRowNumber) @@ -28,20 +24,20 @@ public static GtfsPathway createPathway(int csvRowNumber, Integer pathwayMode, * Tests that a pathway with bidirectional exit gates generates a notice. */ @Test - public void isBidirectionalExitGatesShouldGenerateNotice() { + public void isBidirectionalExitGateShouldGenerateNotice() { GtfsPathway entity = createPathway(1, 7, GtfsPathwayIsBidirectional.BIDIRECTIONAL); NoticeContainer noticeContainer = new NoticeContainer(); - new PathwayBidirectionalExitGatesValidator() + new BidirectionalExitGateValidator() .validate(entity, noticeContainer); assertThat(noticeContainer.getValidationNotices()).containsExactly( - new PathwayBidirectionalExitGatesValidator.PathwayBidirectionalExitGatesNotice(entity)); + new BidirectionalExitGateValidator.BidirectionalExitGatesNotice(entity)); } @Test - public void isNotBidirectionalExitGatesShouldNotGenerateNotice() { + public void isNotBidirectionalExitGateShouldNotGenerateNotice() { GtfsPathway entity = createPathway(1, 7, GtfsPathwayIsBidirectional.UNIDIRECTIONAL); NoticeContainer noticeContainer = new NoticeContainer(); - new PathwayBidirectionalExitGatesValidator() + new BidirectionalExitGateValidator() .validate(entity, noticeContainer); assertThat(noticeContainer.getValidationNotices()).isEmpty(); }