Class SmithyTestCase


  • public final class SmithyTestCase
    extends java.lang.Object
    Runs a single test case by loading a model and ensuring the resulting events match the validation events stored in a newline separated file.
    • Constructor Detail

      • SmithyTestCase

        public SmithyTestCase​(java.lang.String modelLocation,
                              java.util.List<ValidationEvent> expectedEvents)
        Parameters:
        modelLocation - Location of where the model is stored.
        expectedEvents - The expected validation events to encounter.
    • Method Detail

      • fromModelFile

        public static SmithyTestCase fromModelFile​(java.lang.String modelLocation)
        Creates a test case from a model file.

        The error file is expected to be stored in the same directory as the model file and is assumed to be named the same as the file with the file extension replaced with ".errors".

        The accompanying error file is a newline separated list of error strings, where each error is defined in the following format: [SEVERITY] shapeId message | EventId filename:line:column. A shapeId of "-" means that a specific shape is not targeted.

        Parameters:
        modelLocation - File location of the model.
        Returns:
        Returns the created test case.
        Throws:
        java.lang.IllegalArgumentException - if the file does not contain an extension.
      • getExpectedEvents

        public java.util.List<ValidationEvent> getExpectedEvents()
        Gets the expected validation events.
        Returns:
        Expected validation events.
      • getModelLocation

        public java.lang.String getModelLocation()
        Gets the location of the model file.
        Returns:
        Model location.
      • createResult

        public SmithyTestCase.Result createResult​(ValidatedResult<Model> validatedResult)
        Creates a test case result from a test case and validated model.

        The validation events encountered while validating a model are compared against the expected validation events. An actual event (A) is considered a match with an expected event (E) if A and E target the same shape, have the same severity, the eventId of A contains the eventId of E, and the message of E starts with the suppression reason or message of A.

        Parameters:
        validatedResult - Result of creating and validating the model.
        Returns:
        Returns the created test case result.