java.lang.Object
software.amazon.smithy.model.validation.testrunner.SmithyTestCase

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)
      Parameters:
      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.

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

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

      public 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, use the same validation event ID, have the same severity, 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.