use of edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel in project gtfs-realtime-validator by CUTR-at-USF.
the class UtilTest method testAssertResultsThrowExceptionMoreActual.
@Test(expected = AssertionError.class)
public void testAssertResultsThrowExceptionMoreActual() {
// Make sure we fail if we have actual results that weren't expected
List<ErrorListHelperModel> results = new ArrayList<>();
MessageLogModel modelE001 = new MessageLogModel(E001);
OccurrenceModel errorE001 = new OccurrenceModel(String.valueOf(MIN_POSIX_TIME));
List<OccurrenceModel> errorListE001 = new ArrayList<>();
errorListE001.add(errorE001);
results.add(new ErrorListHelperModel(modelE001, errorListE001));
Map<ValidationRule, Integer> expected = new HashMap<>();
// No expected results included for E001, but there is one actual error for E001 - this should throw an AssertionError
TestUtils.assertResults(expected, results);
}
use of edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel in project gtfs-realtime-validator by CUTR-at-USF.
the class UtilTest method testAssertResultsThrowExceptionMismatchActualExpected.
@Test(expected = AssertionError.class)
public void testAssertResultsThrowExceptionMismatchActualExpected() {
// Make sure we fail if we have actual results that don't match the expected results
List<ErrorListHelperModel> results = new ArrayList<>();
MessageLogModel modelE001 = new MessageLogModel(E001);
OccurrenceModel errorE001 = new OccurrenceModel(String.valueOf(MIN_POSIX_TIME));
List<OccurrenceModel> errorListE001 = new ArrayList<>();
errorListE001.add(errorE001);
results.add(new ErrorListHelperModel(modelE001, errorListE001));
Map<ValidationRule, Integer> expected = new HashMap<>();
expected.put(E002, 1);
// We are expecting error for E002, but get one for E001 - this should throw an AssertionError
TestUtils.assertResults(expected, results);
}
use of edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel in project gtfs-realtime-validator by CUTR-at-USF.
the class UtilTest method testAssertResults.
/**
* Make sure our utility method TestUtils.assertResults() properly asserts number of expected==actual
* rule occurrences
*/
@Test
public void testAssertResults() {
MessageLogModel modelE001 = new MessageLogModel(E001);
OccurrenceModel errorE001 = new OccurrenceModel(String.valueOf(MIN_POSIX_TIME));
List<OccurrenceModel> errorListE001 = new ArrayList<>();
List<ErrorListHelperModel> results = new ArrayList<>();
Map<ValidationRule, Integer> expected = new HashMap<>();
// Test empty list of error results and empty hashmap
TestUtils.assertResults(expected, results);
// Test list of error results, but without a MessageLogModel
results.add(new ErrorListHelperModel(modelE001, errorListE001));
TestUtils.assertResults(expected, results);
// Test list of error results, with one MessageLogModel
errorListE001.add(errorE001);
expected.put(E001, 1);
TestUtils.assertResults(expected, results);
// Test list of error results, with two MessageLogModels
errorListE001.add(errorE001);
expected.put(E001, 2);
TestUtils.assertResults(expected, results);
}
use of edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel in project gtfs-realtime-validator by CUTR-at-USF.
the class UtilTest method testAssertResultsThrowExceptionMoreExpected.
@Test(expected = AssertionError.class)
public void testAssertResultsThrowExceptionMoreExpected() {
// Make sure we fail if we have expected occurrences that aren't included in results
List<ErrorListHelperModel> results = new ArrayList<>();
MessageLogModel modelE001 = new MessageLogModel(E001);
OccurrenceModel errorE001 = new OccurrenceModel(String.valueOf(MIN_POSIX_TIME));
List<OccurrenceModel> errorListE001 = new ArrayList<>();
errorListE001.add(errorE001);
results.add(new ErrorListHelperModel(modelE001, errorListE001));
Map<ValidationRule, Integer> expected = new HashMap<>();
expected.put(E001, 1);
// We're expecting 1 error for E001 and 1 error for E002, but get one actual error for E001 - this should throw an AssertionError
expected.put(E002, 1);
TestUtils.assertResults(expected, results);
}
use of edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel in project gtfs-realtime-validator by CUTR-at-USF.
the class StopLocationTypeValidator method validate.
@Override
public List<ErrorListHelperModel> validate(GtfsDaoImpl gtfsData) {
List<OccurrenceModel> e010List = new ArrayList<>();
Collection<StopTime> stopTimes = gtfsData.getAllStopTimes();
Set<Stop> checkedStops = new HashSet<>();
for (StopTime stopTime : stopTimes) {
if (!checkedStops.contains(stopTime.getStop())) {
checkedStops.add(stopTime.getStop());
if (stopTime.getStop().getLocationType() != 0) {
RuleUtils.addOccurrence(E010, "stop_id " + stopTime.getStop().getId(), e010List, _log);
}
}
}
List<ErrorListHelperModel> errors = new ArrayList<>();
if (!e010List.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(E010), e010List));
}
return errors;
}
Aggregations