Package software.amazon.smithy.build
Class MockManifest
java.lang.Object
software.amazon.smithy.build.MockManifest
- All Implemented Interfaces:
FileManifest
A
FileManifest
that doesn't actually store files on disk.
This manifest is useful for testing SmithyBuildPlugin implementations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The way in which files are stored. -
Constructor Summary
ConstructorDescriptionCreates a mock manifest that stores files in memory and uses a base directory of "/".MockManifest
(Path baseDir) Creates a mock manifest that stores files in memory.MockManifest
(Path baseDir, MockManifest.StoreMode storeMode) -
Method Summary
Modifier and TypeMethodDescriptionAdds a path to the manifest.byte[]
expectFileBytes
(String file) Expects that the given file was stored and returns the bytes.byte[]
expectFileBytes
(Path file) Expects that the given file was stored and returns the bytes.expectFileString
(String file) Expects that the given file was stored and returns a UTF-8 string.expectFileString
(Path file) Expects that the given file was stored and returns a UTF-8 string.Gets the base directory of the manifest.Optional<byte[]>
getFileBytes
(String file) Gets the bytes of a stored file.Optional<byte[]>
getFileBytes
(Path file) Gets the bytes of a stored file.getFiles()
Gets all of the files in the result.getFileString
(String file) Gets the contents of a stored file as a String.getFileString
(Path file) Gets the contents of a stored file as a String.writeFile
(Path path, InputStream fileContentsInputStream) Adds a file to the result using the contents of anInputStream
.Adds a file to the result using the contents of aReader
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.smithy.build.FileManifest
addAllFiles, getFilesIn, getFilesIn, hasFile, hasFile, resolvePath, writeFile, writeFile, writeFile, writeFile, writeFile, writeFile, writeJson, writeJson
-
Constructor Details
-
MockManifest
- Parameters:
baseDir
- Base directory of the manifest.storeMode
- How files are stored in the mock.
-
MockManifest
Creates a mock manifest that stores files in memory.- Parameters:
baseDir
- Base directory of the manifest.
-
MockManifest
public MockManifest()Creates a mock manifest that stores files in memory and uses a base directory of "/".
-
-
Method Details
-
getBaseDir
Description copied from interface:FileManifest
Gets the base directory of the manifest.- Specified by:
getBaseDir
in interfaceFileManifest
- Returns:
- Returns the base directory.
-
getFiles
Description copied from interface:FileManifest
Gets all of the files in the result.The order of files returned should be stable across calls.
- Specified by:
getFiles
in interfaceFileManifest
- Returns:
- Returns the files in the manifest.
-
addFile
Description copied from interface:FileManifest
Adds a path to the manifest.The given path must be relative or within the base directory.
- Specified by:
addFile
in interfaceFileManifest
- Parameters:
path
- Path to add.- Returns:
- Returns the path resolved against any base URL.
-
writeFile
Description copied from interface:FileManifest
Adds a file to the result using the contents of aReader
.This method will write the contents of a Reader to a file.
- Specified by:
writeFile
in interfaceFileManifest
- Parameters:
path
- Relative path to the file to create.fileContentsReader
- Reader to consume and write to the file.- Returns:
- Returns the resolved path.
-
writeFile
Description copied from interface:FileManifest
Adds a file to the result using the contents of anInputStream
.This method will write the contents of an input stream to a file.
- Specified by:
writeFile
in interfaceFileManifest
- Parameters:
path
- Relative path to the file to create.fileContentsInputStream
- InputStream to consume and write to the file.- Returns:
- Returns the resolved path.
-
getFileString
Gets the contents of a stored file as a String.- Parameters:
file
- Relative or absolute path to the file to retrieve.- Returns:
- Returns the optionally found file string.
- Throws:
SmithyBuildException
- if the file cannot be read as UTF-8.
-
getFileString
Gets the contents of a stored file as a String.- Parameters:
file
- Relative or absolute path to the file to retrieve.- Returns:
- Returns the optionally found file string.
- Throws:
SmithyBuildException
- if the file cannot be read as UTF-8.
-
expectFileString
Expects that the given file was stored and returns a UTF-8 string.- Parameters:
file
- File to retrieve.- Returns:
- Returns the bytes of the file if found.
- Throws:
InvalidPathException
- if the file cannot be found.
-
expectFileString
Expects that the given file was stored and returns a UTF-8 string.- Parameters:
file
- File to retrieve.- Returns:
- Returns the bytes of the file if found.
- Throws:
InvalidPathException
- if the file cannot be found.
-
getFileBytes
Gets the bytes of a stored file.- Parameters:
file
- Relative or absolute path to the file to retrieve.- Returns:
- Returns the optionally found file by.es,
-
getFileBytes
Gets the bytes of a stored file.- Parameters:
file
- Relative or absolute path to the file to retrieve.- Returns:
- Returns the optionally found file by.es,
-
expectFileBytes
Expects that the given file was stored and returns the bytes.- Parameters:
file
- File to retrieve.- Returns:
- Returns the bytes of the file if found.
- Throws:
InvalidPathException
- if the file cannot be found.
-
expectFileBytes
Expects that the given file was stored and returns the bytes.- Parameters:
file
- File to retrieve.- Returns:
- Returns the bytes of the file if found.
- Throws:
InvalidPathException
- if the file cannot be found.
-