Class SmithyDiffTestCase


  • public final class SmithyDiffTestCase
    extends java.lang.Object
    Runs a single test case by loading corresponding models `a` and `b` and ensuring the resulting events match the diff events stored in a `-----` separated file.
    • Constructor Detail

      • SmithyDiffTestCase

        public SmithyDiffTestCase​(java.nio.file.Path path,
                                  java.lang.String name,
                                  java.util.List<ValidationEvent> expectedEvents)
        Parameters:
        path - Parent path of where the model and event files are stored.
        name - Name of the test case
        expectedEvents - The expected diff events to encounter.
    • Method Detail

      • from

        public static SmithyDiffTestCase from​(java.nio.file.Path path,
                                              java.lang.String name)
        Creates a test case from a test case path and name.

        The models and events file are expected to be stored in the same directory as the model and events file are assumed to be named the same barring the file extensions: `.a.(json|smithy)`, `.b.(json|smithy)`, `.events`.

        The accompanying events file is a `-----` separated list of event strings, where each event 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:
        path - Parent path of where the model and event files are stored.
        name - Name of the test case
        Returns:
        Returns the created test case.
      • getPath

        public java.nio.file.Path getPath()
        Gets the parent path of the test case.
        Returns:
        parent path of the test case.
      • getName

        public java.lang.String getName()
        Gets the name of the test case.
        Returns:
        name of the test case.
      • getExpectedEvents

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

        public SmithyDiffTestCase.Result createResult​(java.util.List<ValidationEvent> actualEvents)
        Creates a test case result from a list of model diff events.

        The diff events encountered 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:
        actualEvents - List of actual diff events.
        Returns:
        Returns the created test case result.