public class ManagedTestData extends java.lang.Object
TestDataManager
.Constructor and Description |
---|
ManagedTestData(java.lang.Class<?> contextClass) |
Modifier and Type | Method and Description |
---|---|
java.io.File |
copyDataDirectory(java.lang.String directoryName,
java.io.File tempDir)
Creates a copy of the given resource directory in the given tempDir.
|
java.lang.String |
getDataContent(java.lang.String path)
Returns the content of given resource.
|
java.io.File |
getDataFile(java.lang.String fileName)
Returns a copy of the given resource as temporary file.
|
java.io.File |
getDataFile(java.lang.String fileName,
java.io.File tempDir)
Returns a copy of the given resource as temporary file.
|
Resource |
getResource(java.lang.String path)
Returns the given resource.
|
java.util.Optional<Resource> |
getResourceIfExists(java.lang.String path)
Returns the given resource or an empty optional if no resource with the given
path exists.
|
java.util.List<Resource> |
listResources(java.lang.String subfolder,
java.util.function.Predicate<Resource> filter)
Lists all resources contained in the given subfolder matching the given
predicate.
|
java.util.List<Resource> |
listResources(java.lang.String subfolder,
java.lang.String... fileExtensions)
Lists all resources contained in the given subfolder.
|
java.util.List<Resource> |
listResourcesRecursively(java.lang.String subfolder,
java.util.function.Predicate<Resource> filter)
Lists all resources contained in the given subfolder recursively matching the
given predicate.
|
java.util.List<Resource> |
listResourcesRecursively(java.lang.String subfolder,
java.lang.String... fileExtensions)
Lists all resources contained in the given subfolder recursively.
|
public ManagedTestData(java.lang.Class<?> contextClass)
contextClass
- The (test) class using the managed test data. The package of the
class determines the root folder that is used for resource
lookups.public Resource getResource(java.lang.String path)
public java.util.Optional<Resource> getResourceIfExists(java.lang.String path)
public java.lang.String getDataContent(java.lang.String path)
getResource(String)
and Resource.getContentAsRawString()
or
Resource.getAsByteArray()
instead.public java.io.File getDataFile(java.lang.String fileName)
getDataFile(String, File)
instead, which allows you to copy into a
given temporary directory under the original file name.public java.io.File getDataFile(java.lang.String fileName, java.io.File tempDir)
public java.io.File copyDataDirectory(java.lang.String directoryName, java.io.File tempDir)
public java.util.List<Resource> listResources(java.lang.String subfolder, java.lang.String... fileExtensions)
public java.util.List<Resource> listResources(java.lang.String subfolder, java.util.function.Predicate<Resource> filter)
public java.util.List<Resource> listResourcesRecursively(java.lang.String subfolder, java.lang.String... fileExtensions)
public java.util.List<Resource> listResourcesRecursively(java.lang.String subfolder, java.util.function.Predicate<Resource> filter)