public class FileChecksumMatcher extends TypeSafeMatcher<PipelineResult> implements SerializableMatcher<PipelineResult>
For example:
assertThat(job, new FileChecksumMatcher(checksumString, filePath));
or
assertThat(job, new FileChecksumMatcher(checksumString, filePath, shardTemplate));
Checksum of outputs is generated based on SHA-1 algorithm. If output file is empty, SHA-1 hash of empty string (da39a3ee5e6b4b0d3255bfef95601890afd80709) is used as expected.
Constructor and Description |
---|
FileChecksumMatcher(java.lang.String expectedChecksum,
org.apache.beam.sdk.util.ShardedFile shardedFile)
Constructor using an entirely custom
ShardedFile implementation. |
FileChecksumMatcher(java.lang.String checksum,
java.lang.String filePath)
Constructor that uses default shard template.
|
FileChecksumMatcher(java.lang.String checksum,
java.lang.String filePath,
java.util.regex.Pattern shardTemplate)
Constructor using a custom shard template.
|
Modifier and Type | Method and Description |
---|---|
void |
describeMismatchSafely(PipelineResult pResult,
Description description) |
void |
describeTo(Description description) |
boolean |
matchesSafely(PipelineResult pipelineResult) |
describeMismatch, matches
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, matches
public FileChecksumMatcher(java.lang.String checksum, java.lang.String filePath)
checksum
- expected checksum string used to verify file content.filePath
- path of files that's to be verified.public FileChecksumMatcher(java.lang.String checksum, java.lang.String filePath, java.util.regex.Pattern shardTemplate)
checksum
- expected checksum string used to verify file content.filePath
- path of files that's to be verified.shardTemplate
- template of shard name to parse out the total number of shards which is
used in I/O retry to avoid inconsistency of filesystem. Customized template should assign
name "numshards" to capturing group - total shard number.public FileChecksumMatcher(java.lang.String expectedChecksum, org.apache.beam.sdk.util.ShardedFile shardedFile)
ShardedFile
implementation.
For internal use only.
public boolean matchesSafely(PipelineResult pipelineResult)
matchesSafely
in class TypeSafeMatcher<PipelineResult>
public void describeTo(Description description)
describeTo
in interface SelfDescribing
public void describeMismatchSafely(PipelineResult pResult, Description description)
describeMismatchSafely
in class TypeSafeMatcher<PipelineResult>