public final class SmithyTestCase extends 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 Details

    • SmithyTestCase

      public SmithyTestCase(String modelLocation, List<ValidationEvent> expectedEvents)
      modelLocation - Location of where the model is stored.
      expectedEvents - The expected validation events to encounter.
  • Method Details

    • fromModelFile

      public static SmithyTestCase fromModelFile(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.

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

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

      public String getModelLocation()
      Gets the location of the model file.
      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.

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