Class AbstractTestSuite
java.lang.Object
gov.nist.secauto.metaschema.model.testing.AbstractTestSuite
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Path
convertContent
(URI resource, Path generationPath, IBindingContext context) Perform content conversion.protected void
deleteCollectionOnExit
(Path path) Configure removal of the provided directory after test execution.protected void
generateSchema
(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 Path
Get the filesystem location to use for generating content.protected abstract Format
Get 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 URI
Get 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 boolean
validateWithSchema
(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.- 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:
true
if the content is valid orfalse
otherwise- Throws:
IOException
- if an error occurred while reading the content
-