Search in sources :

Example 6 with OccurrenceModel

use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel in project gtfs-realtime-validator by CUTR-at-USF.

the class RuleUtils method addOccurrence.

/**
 * Adds occurrence for rule
 *
 * @param rule               rule to add occurrence for
 * @param occurrencePrefix   prefix to use for the OccurrenceModel constructor
 * @param list               list to add occurrence for the rule to
 * @param log                logger to use to output occurrence info
 */
public static void addOccurrence(ValidationRule rule, String occurrencePrefix, List<OccurrenceModel> list, org.slf4j.Logger log) {
    OccurrenceModel om = new OccurrenceModel(occurrencePrefix);
    list.add(om);
    log.debug(om.getPrefix() + " " + rule.getOccurrenceSuffix());
}
Also used : OccurrenceModel(edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel)

Example 7 with OccurrenceModel

use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel 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);
}
Also used : ErrorListHelperModel(edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel) MessageLogModel(edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel) OccurrenceModel(edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) Test(org.junit.Test)

Example 8 with OccurrenceModel

use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel 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);
}
Also used : ErrorListHelperModel(edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel) MessageLogModel(edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel) OccurrenceModel(edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) Test(org.junit.Test)

Example 9 with OccurrenceModel

use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel 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);
}
Also used : MessageLogModel(edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel) ErrorListHelperModel(edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel) OccurrenceModel(edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) Test(org.junit.Test)

Example 10 with OccurrenceModel

use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel 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);
}
Also used : ErrorListHelperModel(edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel) MessageLogModel(edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel) OccurrenceModel(edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel) ValidationRule(edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule) Test(org.junit.Test)

Aggregations

OccurrenceModel (edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel)16 MessageLogModel (edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel)14 ErrorListHelperModel (edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel)14 GtfsRealtime (com.google.transit.realtime.GtfsRealtime)9 ArrayList (java.util.ArrayList)8 ValidationRule (edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule)4 Test (org.junit.Test)4 Stop (org.onebusaway.gtfs.model.Stop)2 StopTime (org.onebusaway.gtfs.model.StopTime)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Session (org.hibernate.Session)1 Frequency (org.onebusaway.gtfs.model.Frequency)1 Trip (org.onebusaway.gtfs.model.Trip)1