Skip to content

Commit

Permalink
renamed validator and notice
Browse files Browse the repository at this point in the history
  • Loading branch information
qcdyx committed Aug 29, 2024
1 parent d3548be commit 02e7713
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* </ul>
*/
@GtfsValidator
public class PathwayBidirectionalExitGatesValidator extends SingleEntityValidator<GtfsPathway> {
public class BidirectionalExitGateValidator extends SingleEntityValidator<GtfsPathway> {

@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));
}
}

Expand All @@ -32,18 +32,18 @@ public void validate(GtfsPathway entity, NoticeContainer noticeContainer) {
* <p>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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
}
Expand Down

0 comments on commit 02e7713

Please sign in to comment.