Package de.skuzzle.test.snapshots
Class SnapshotFile
- java.lang.Object
-
- de.skuzzle.test.snapshots.SnapshotFile
-
@API(status=EXPERIMENTAL) public final class SnapshotFile extends java.lang.ObjectA snapshot file is a plain text file containing a header and the actual serialized snapshot. The header is a simple key-value format which is separated from the actual snapshot contents by two line breaks (\n). Snapshot files are always encoded in UTF-8.You can use this class to manually read the contents of a persisted snapshot file.
This class is immutable and only holds the file's contents. It is not a reference to the actually stored file.
- Since:
- 0.0.5
- See Also:
SnapshotTestResult
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnapshotFile.SnapshotHeader
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SnapshotFilechangeHeader(SnapshotFile.SnapshotHeader newHeader)Creates a newSnapshotFileinstance with the given header and the same snapshot contents.booleanequals(java.lang.Object obj)static SnapshotFilefromSnapshotFile(java.nio.file.Path file)inthashCode()SnapshotFile.SnapshotHeaderheader()Header information to this snapshot that are written by the framework.static SnapshotFileof(SnapshotFile.SnapshotHeader header, java.lang.String snapshot)static SnapshotFilereadFrom(java.io.BufferedReader reader)java.lang.Stringsnapshot()The serialized snapshot.SnapshotFilewriteTo(java.nio.file.Path snapshotFile)Writes this object to the specified file, potentially overriding it if it already exists.
-
-
-
Method Detail
-
of
public static SnapshotFile of(SnapshotFile.SnapshotHeader header, java.lang.String snapshot)
-
fromSnapshotFile
public static SnapshotFile fromSnapshotFile(java.nio.file.Path file) throws java.io.IOException
- Throws:
java.io.IOException
-
readFrom
public static SnapshotFile readFrom(java.io.BufferedReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
changeHeader
@API(status=EXPERIMENTAL, since="1.2.1") public SnapshotFile changeHeader(SnapshotFile.SnapshotHeader newHeader)Creates a newSnapshotFileinstance with the given header and the same snapshot contents.- Parameters:
newHeader- The new header.- Returns:
- A new
SnapshotFileinstance. - Since:
- 1.2.1
-
header
public SnapshotFile.SnapshotHeader header()
Header information to this snapshot that are written by the framework.- Returns:
- The header.
-
snapshot
public java.lang.String snapshot()
The serialized snapshot. This is the string that has been produced by theSnapshotSerializerin place.- Returns:
- The serialized snapshot string.
-
writeTo
public SnapshotFile writeTo(java.nio.file.Path snapshotFile) throws java.io.IOException
Writes this object to the specified file, potentially overriding it if it already exists.- Parameters:
snapshotFile- The target file to write to.- Returns:
- The instance.
- Throws:
java.io.IOException- If an IO error occurs during writing.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-