Package org.apache.beam.sdk.testing
Class FileChecksumMatcher
java.lang.Object
org.hamcrest.BaseMatcher<org.apache.beam.sdk.util.ShardedFile>
org.hamcrest.TypeSafeMatcher<org.apache.beam.sdk.util.ShardedFile>
org.apache.beam.sdk.testing.FileChecksumMatcher
- All Implemented Interfaces:
Serializable
,SerializableMatcher<org.apache.beam.sdk.util.ShardedFile>
,Matcher<org.apache.beam.sdk.util.ShardedFile>
,SelfDescribing
public class FileChecksumMatcher
extends TypeSafeMatcher<org.apache.beam.sdk.util.ShardedFile>
implements SerializableMatcher<org.apache.beam.sdk.util.ShardedFile>
Matcher to verify checksum of the contents of an
ShardedFile
in E2E test.
For example:
assertThat(new NumberedShardedFile(filePath), fileContentsHaveChecksum(checksumString));
or
assertThat(new NumberedShardedFile(filePath, shardTemplate), fileContentsHaveChecksum(checksumString));
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.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
describeMismatchSafely
(org.apache.beam.sdk.util.ShardedFile shardedFile, Description description) void
describeTo
(Description description) static FileChecksumMatcher
fileContentsHaveChecksum
(String checksum) boolean
matchesSafely
(org.apache.beam.sdk.util.ShardedFile shardedFile) Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.hamcrest.Matcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, matches
-
Method Details
-
fileContentsHaveChecksum
-
matchesSafely
public boolean matchesSafely(org.apache.beam.sdk.util.ShardedFile shardedFile) - Specified by:
matchesSafely
in classTypeSafeMatcher<org.apache.beam.sdk.util.ShardedFile>
-
describeTo
- Specified by:
describeTo
in interfaceSelfDescribing
-
describeMismatchSafely
public void describeMismatchSafely(org.apache.beam.sdk.util.ShardedFile shardedFile, Description description) - Overrides:
describeMismatchSafely
in classTypeSafeMatcher<org.apache.beam.sdk.util.ShardedFile>
-