public class ExpectedDataContainer extends java.lang.Object
expectedResource
that holds the expected output
of the test case and test resources that are considered to belong to the
container by some naming heuristics.
A container is formed around an expected file (default suffix is ".expected"
if not stated differently in
ExpectedResourceSource.expectedSuffix()
). All files that have a
longer common path prefix with expected file X than with any other expected
file, belong to the test container of X.
The "primary test resource" is the file exactly matching the expected file
name without extension.
Example Setups:
folder/A.java <- container "folder/A.java", primary resource folder/A.java.expected <- container "folder/A.java", expected resource folder/B.cpp <- container "folder/B.cpp", primary resource folder/BHeader.h <- container "folder/B.cpp" folder/B.cpp.expected <- container "folder/B.cpp", expected resource folder/subfolder/B.metadata <- container "folder/subfolder/B.java" folder/subfolder/B.java <- container "folder/subfolder/B.java", primary resource folder/subfolder/B.java.expected <- container "folder/subfolder/B.java", expected resource
ExpectedResourceSource
,
of(List, String, String)
Modifier and Type | Method and Description |
---|---|
Resource |
getExpectedResource()
Returns the expected resource of the container.
|
Resource |
getPrimaryTestResource()
Returns the primary test resource, which is the only resource whose name
matches the expected resource without the suffix.
|
Resource |
getSingleTestResource(java.lang.String... suffixes)
Returns a single test resource.
|
java.util.List<Resource> |
getTestResources()
Returns all test resource that belong to the container (not including the
expected resource).
|
static java.util.List<ExpectedDataContainer> |
of(java.util.List<Resource> resources,
java.lang.String path,
java.lang.String expectedSuffix)
Builds a list of
ExpectedDataContainer s out of the given resources. |
java.lang.String |
toString()
Used as test case name.
|
public Resource getExpectedResource()
public java.util.List<Resource> getTestResources()
public Resource getPrimaryTestResource()
public Resource getSingleTestResource(java.lang.String... suffixes)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.List<ExpectedDataContainer> of(java.util.List<Resource> resources, java.lang.String path, java.lang.String expectedSuffix)
ExpectedDataContainer
s out of the given resources.
Resources are grouped by the given expectedSuffix. Files that either start
with the same resource name, the same basename (excluding any file extensions
and suffix numbers) or the same folder (including subfolders) as the
#expectedFile are considered.path
- Is the subpath that was used to search for resources. It is
stripped from the representativeName to make it more readable.