Class AbstractTestSuite
java.lang.Object
gov.nist.secauto.metaschema.model.testing.AbstractTestSuite
This abstract implementation dynamically produces JUnit tests based on a test
suite definition.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PathconvertContent(URI resource, Path generationPath, IBindingContext context) Perform content conversion.protected voiddeleteCollectionOnExit(Path path) Configure removal of the provided directory after test execution.protected voidgenerateSchema(IModule module, Path schemaPath, BiFunction<IModule, Writer, Void> schemaProducer) Generate a schema for the provided module using the provided schema generator.protected abstract Function<Path,? extends IContentValidator> Get the method used to provide a content validator.protected abstract PathGet the filesystem location to use for generating content.protected abstract FormatGet the content format used by the test suite.protected abstract BiFunction<IModule,Writer, Void> Get the method used to generate a schema using a given Metaschema module and writer.protected abstract Supplier<? extends IContentValidator>Get the method used to provide a schema validator.protected abstract URIGet the resource describing the tests to execute.protected OpenOption[]The the options for writing generated content.protected Stream<org.junit.jupiter.api.DynamicNode>testFactory(IBindingContext bindingContext) Dynamically generate the unit tests.protected static booleanvalidateWithSchema(IContentValidator validator, Path target) Use the provided validator to validate the provided target.
-
Constructor Details
-
AbstractTestSuite
public AbstractTestSuite()
-
-
Method Details
-
getRequiredContentFormat
Get the content format used by the test suite.- Returns:
- the format
-
getTestSuiteURI
Get the resource describing the tests to execute.- Returns:
- the resource
-
getGenerationPath
Get the filesystem location to use for generating content.- Returns:
- the filesystem path
-
getSchemaGeneratorSupplier
Get the method used to generate a schema using a given Metaschema module and writer.- Returns:
- the schema generator supplier
-
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(@NonNull IBindingContext bindingContext) Dynamically generate the unit tests.- Parameters:
bindingContext- the Module binding context- Returns:
- the steam of unit tests
-
deleteCollectionOnExit
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, throws IOExceptionVoid> schemaProducer) Generate a schema for the provided module using the provided schema generator.- Parameters:
module- the Metaschema module to generate the schema forschemaPath- the location to generate the schemaschemaProducer- 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 convertgenerationPath- the path to write the converted resource tocontext- 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 usetarget- the resource to validate- Returns:
trueif the content is valid orfalseotherwise- Throws:
IOException- if an error occurred while reading the content
-