Class FileMatcher
java.lang.Object
org.hamcrest.BaseMatcher<File>
io.github.cjstehno.testthings.match.FileMatcher
- All Implemented Interfaces:
org.hamcrest.Matcher<File>,org.hamcrest.SelfDescribing
Matchers useful for matching File information.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.hamcrest.Matcher<File>extensionEqualTo(String extension) Creates a file matcher for matching the file extension (not including the dot).static org.hamcrest.Matcher<File>extensionMatches(org.hamcrest.Matcher<String> extensionMatcher) Creates a file matcher for matching the file extension (not including the dot).static org.hamcrest.Matcher<File>fileBytesMatch(org.hamcrest.Matcher<byte[]> arrayMatcher) Creates a file matcher for matching the content bytes.static org.hamcrest.Matcher<File>Creates a file matcher for matching whether a file exists.static org.hamcrest.Matcher<File>fileSizeMatches(org.hamcrest.Matcher<Long> sizeMatcher) Creates a file matcher for matching the size of a file.static org.hamcrest.Matcher<File>fileTextMatches(org.hamcrest.Matcher<String> stringMatcher) Creates a file matcher for matching the content as a string.static org.hamcrest.Matcher<File>Creates a file matcher for matching whether a file is a directory.static org.hamcrest.Matcher<File>isFile()Creates a file matcher for matching whether a file is a file (not a directory).static org.hamcrest.Matcher<File>Creates a file matcher for matching whether is readable.static org.hamcrest.Matcher<File>/** Creates a file matcher for matching whether a file is writable.static org.hamcrest.Matcher<File>nameEqualTo(String name) Creates a file matcher for matching the file name.static org.hamcrest.Matcher<File>nameMatches(org.hamcrest.Matcher<String> nameMatcher) Creates a file matcher for matching the file name.Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, isNotNull, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hamcrest.Matcher
matchesMethods inherited from interface org.hamcrest.SelfDescribing
describeTo
-
Constructor Details
-
FileMatcher
public FileMatcher()
-
-
Method Details
-
nameMatches
Creates a file matcher for matching the file name.- Parameters:
nameMatcher- the name string matcher- Returns:
- the file matcher
-
nameEqualTo
Creates a file matcher for matching the file name.- Parameters:
name- expected name- Returns:
- the file matcher
-
extensionMatches
public static org.hamcrest.Matcher<File> extensionMatches(org.hamcrest.Matcher<String> extensionMatcher) Creates a file matcher for matching the file extension (not including the dot).- Parameters:
extensionMatcher- the extension string matcher- Returns:
- the file matcher
-
extensionEqualTo
Creates a file matcher for matching the file extension (not including the dot).- Parameters:
extension- the file extension- Returns:
- the file matcher
-
fileExists
Creates a file matcher for matching whether a file exists.- Returns:
- the file matcher
-
isReadable
Creates a file matcher for matching whether is readable.- Returns:
- the file matcher
-
isWritable
/** Creates a file matcher for matching whether a file is writable.- Returns:
- the file matcher
-
isFile
Creates a file matcher for matching whether a file is a file (not a directory).- Returns:
- the file matcher
-
isDirectory
Creates a file matcher for matching whether a file is a directory.- Returns:
- the file matcher
-
fileBytesMatch
Creates a file matcher for matching the content bytes.- Parameters:
arrayMatcher- the byte array matcher- Returns:
- the file matcher
-
fileTextMatches
public static org.hamcrest.Matcher<File> fileTextMatches(org.hamcrest.Matcher<String> stringMatcher) Creates a file matcher for matching the content as a string. Multiline content will be joined with line breaks (i.e. "\n").- Parameters:
stringMatcher- the string text matcher- Returns:
- the file matcher
-
fileSizeMatches
Creates a file matcher for matching the size of a file.- Parameters:
sizeMatcher- the matcher for the size of the file- Returns:
- the file matcher
-