Class AbstractTestSuite

java.lang.Object
gov.nist.secauto.metaschema.model.testing.AbstractTestSuite

public abstract class AbstractTestSuite extends Object
  • Constructor Details

  • Method Details

    • getRequiredContentFormat

      @NonNull protected abstract Format getRequiredContentFormat()
      Get the content format used by the test suite.
      Returns:
      the format
    • getTestSuiteURI

      @NonNull protected abstract URI getTestSuiteURI()
      Get the resource describing the tests to execute.
      Returns:
      the resource
    • getGenerationPath

      @NonNull protected abstract Path getGenerationPath()
      Get the filesystem location to use for generating content.
      Returns:
      the filesystem path
    • getSchemaGeneratorSupplier

      @NonNull protected abstract BiFunction<IModule,Writer,Void> getSchemaGeneratorSupplier()
      Get the method used to generate a schema using a given Metaschema module and writer.
      Returns:
      the schema generator supplier
    • getSchemaValidatorSupplier

      @Nullable protected abstract Supplier<? extends IContentValidator> getSchemaValidatorSupplier()
      Get the method used to provide a schema validator.
      Returns:
      the method as a supplier
    • getContentValidatorSupplier

      @NonNull protected abstract Function<Path,? extends IContentValidator> getContentValidatorSupplier()
      Get the method used to provide a content validator.
      Returns:
      the method as a supplier
    • testFactory

      @NonNull protected Stream<org.junit.jupiter.api.DynamicNode> testFactory()
      Dynamically generate the unit tests.
      Returns:
      the steam of unit tests
    • deleteCollectionOnExit

      protected void deleteCollectionOnExit(@NonNull Path path)
      Configure removal of the provided directory after test execution.
      Parameters:
      path - the directory to configure for removal
    • generateSchema

      protected void generateSchema(@NonNull IModule module, @NonNull Path schemaPath, @NonNull BiFunction<IModule,Writer,Void> schemaProducer) throws IOException
      Generate a schema for the provided module using the provided schema generator.
      Parameters:
      module - the Metaschema module to generate the schema for
      schemaPath - the location to generate the schema
      schemaProducer - the method callback to use to generate the schema
      Throws:
      IOException - if an error occurred while writing the schema
    • getWriteOpenOptions

      The the options for writing generated content.
      Returns:
      the options
    • convertContent

      protected Path convertContent(@NonNull URI resource, @NonNull Path generationPath, @NonNull IBindingContext context) throws IOException
      Perform content conversion.
      Parameters:
      resource - the resource to convert
      generationPath - the path to write the converted resource to
      context - the Metaschema binding context
      Returns:
      the location of the converted content
      Throws:
      IOException - if an error occurred while reading or writing content
      See Also:
    • validateWithSchema

      protected static boolean validateWithSchema(@NonNull IContentValidator validator, @NonNull Path target) throws IOException
      Use the provided validator to validate the provided target.
      Parameters:
      validator - the content validator to use
      target - the resource to validate
      Returns:
      true if the content is valid or false otherwise
      Throws:
      IOException - if an error occurred while reading the content