### CustomMatcher Example Usage Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomMatcher.html An example demonstrating how to create a non-empty string matcher using CustomMatcher. ```APIDOC ## Example Usage ```java Matcher aNonEmptyString = new CustomMatcher("a non empty string") { public boolean matches(Object object) { return ((object instanceof String) && !((String) object).isEmpty()); } }; ``` ### Description This example shows how to define a custom matcher for strings that are not empty. It uses an anonymous inner class to implement the `matches` method. ``` -------------------------------- ### descriptionStart Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsArray.html Returns the string that starts the description of the matcher. This can be overridden to customize the description. ```APIDOC ## descriptionStart ```java protected String descriptionStart() ``` ### Description Returns the string that starts the description. Can be overridden in subclasses to customise how the matcher is described. ### Returns The description prefix. ``` -------------------------------- ### descriptionStart() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Returns the string that starts the description of an array. This is part of the `IsArray` matcher's description formatting. ```APIDOC ## descriptionStart() ### Description Returns the string that starts the description of an array. This is part of the `IsArray` matcher's description formatting. ### Method Signature `String descriptionStart()` ### Implemented By - `org.hamcrest.collection.IsArray` ``` -------------------------------- ### Example Usage of emptyString Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/IsEmptyString.html Demonstrates how to use the `emptyString()` matcher with `assertThat` to verify an empty string. ```java assertThat("", is(emptyString())) ``` -------------------------------- ### Example usage of isIn with a Collection Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsIn.html This example demonstrates how to use the `isIn` matcher with a `java.util.Collection`. It asserts that the string "foo" is present in the provided list. ```java assertThat("foo", isIn(Arrays.asList("bar", "foo"))) ``` -------------------------------- ### startsWithIgnoringCase(String prefix) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Creates a matcher that checks if the examined String starts with the specified prefix, ignoring case differences. ```APIDOC ## startsWithIgnoringCase(String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String, ignoring case. ### Method Signature `static Matcher startsWithIgnoringCase(String prefix)` ``` -------------------------------- ### StringStartsWith Class Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/allclasses-index.html Tests if a string starts with a specific substring. ```APIDOC ## StringStartsWith ### Description Tests if the argument is a string that starts with a specific substring. ### Class `org.hamcrest.core.StringStartsWith` ``` -------------------------------- ### StringStartsWith.startsWith(String) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Creates a matcher that matches if the examined String starts with the specified String. ```APIDOC ## Static Method StringStartsWith.startsWith(String) ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Parameters * **prefix** (String) - The prefix to match against. ``` -------------------------------- ### CoreMatchers.startsWith(String) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Creates a matcher that matches if the examined String starts with the specified String. ```APIDOC ## Static Method CoreMatchers.startsWith(String) ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Parameters * **prefix** (String) - The prefix to match against. ``` -------------------------------- ### startsWith(String prefix) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Creates a matcher that checks if the examined String starts with the specified prefix. ```APIDOC ## startsWith(String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Method Signature `static Matcher startsWith(String prefix)` ``` -------------------------------- ### Example Usage of HasToString with Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/object/HasToString.html This example shows how to use the hasToString(Matcher) matcher with an equalTo matcher to assert that the toString() representation of an object is equal to 'TRUE'. ```java assertThat(true, hasToString(equalTo("TRUE"))) ``` -------------------------------- ### CustomTypeSafeMatcher Example Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomTypeSafeMatcher.html This example demonstrates how to create a custom matcher for a non-empty string using CustomTypeSafeMatcher. ```APIDOC ## CustomTypeSafeMatcher Usage Example ### Description This example shows how to define a custom matcher for a non-empty string. ### Class `CustomTypeSafeMatcher` ### Constructor `CustomTypeSafeMatcher(String description)` ### Methods - `boolean matchesSafely(T item)`: Implement this method to define the matching logic. - `void describeMismatchSafely(T item, Description mismatchDescription)`: Implement this to describe why a match failed. ### Code Example ```java Matcher aNonEmptyString = new CustomTypeSafeMatcher("a non empty string") { @Override public boolean matchesSafely(String string) { return !string.isEmpty(); } @Override public void describeMismatchSafely(String string, Description mismatchDescription) { mismatchDescription.appendText("was empty"); } }; ``` ``` -------------------------------- ### String Starts With Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Use this matcher to assert that a string begins with a specific prefix. Ensure the prefix is provided as a String argument. ```java assertThat("myStringOfNote", startsWith("my")) ``` -------------------------------- ### StringStartsWith Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Tests if the argument is a string that starts with a specific substring. ```APIDOC ## StringStartsWith ### Description Tests if the argument is a string that starts with a specific substring. ### Constructors `StringStartsWith(boolean ignoreCase, String prefix)` Constructor, best used with `StringStartsWith.startsWith(String)` or `StringStartsWith.startsWithIgnoringCase(String)`. `StringStartsWith(String prefix)` Constructor, best used with `StringStartsWith.startsWith(String)`. ``` -------------------------------- ### Example Usage of HasToString with String Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/object/HasToString.html This example demonstrates how to use the hasToString(String) matcher to assert that the toString() representation of an object is exactly 'TRUE'. ```java assertThat(true, hasToString("TRUE")) ``` -------------------------------- ### Example Usage of BigDecimalCloseTo Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/number/BigDecimalCloseTo.html Demonstrates how to use the closeTo matcher with assertThat to verify if a BigDecimal value is approximately equal to an expected value within a given tolerance. ```java assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03")))) ``` -------------------------------- ### String Prefix Matchers Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Provides matchers to assert if a string starts with a specific prefix, with an option to ignore case. ```APIDOC ## startsWith ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Method Signature `public static Matcher startsWith(String prefix)` ### Parameters * `prefix` (String) - The substring that the returned matcher will expect at the start of any examined string. ### Returns A Matcher that asserts the string starts with the given prefix. ### Example `assertThat("myStringOfNote", startsWith("my"))` ## startsWithIgnoringCase ### Description Creates a matcher that matches if the examined String starts with the specified String, ignoring case. ### Method Signature `public static Matcher startsWithIgnoringCase(String prefix)` ### Parameters * `prefix` (String) - The substring that the returned matcher will expect at the start of any examined string. ### Returns A Matcher that asserts the string starts with the given prefix, ignoring case. ### Example `assertThat("myStringOfNote", startsWithIgnoringCase("My"))` ``` -------------------------------- ### Example Usage of IsArray Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsArray.html Demonstrates how to use the IsArray matcher with assertThat to check if an integer array matches a sequence of expected values. Ensure the number of matchers corresponds to the array size. ```java assertThat(new Integer[]{1,2,3}, is(array(equalTo(1), equalTo(2), equalTo(3)))) ``` -------------------------------- ### Match String Starts With Prefix Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Use this matcher to assert that a string begins with a specific prefix. Case-sensitive. ```java assertThat(string, startsWith("prefix")) ``` -------------------------------- ### Creating a Custom String Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomMatcher.html Example of creating a custom matcher for strings that checks if the string is non-empty. This demonstrates the typical usage pattern with an anonymous inner class. ```java Matcher aNonEmptyString = new CustomMatcher("a non empty string") { public boolean matches(Object object) { return ((object instanceof String) && !((String) object).isEmpty(); } }; ``` -------------------------------- ### String Starts With Ignoring Case Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Use this matcher to assert that a string begins with a specific prefix, disregarding case differences. Provide the prefix as a String argument. ```java assertThat("myStringOfNote", startsWithIgnoringCase("My")) ``` -------------------------------- ### IsAnything() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor for IsAnything, best called from IsAnything.anything(). ```APIDOC ## IsAnything() ### Description Constructor, best called from [`IsAnything.anything()`](org/hamcrest/core/IsAnything.html#anything()). ### Class org.hamcrest.core.IsAnything ``` -------------------------------- ### IsAnything Matcher Creation Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Provides static factory methods to create IsAnything matchers. The `anything()` method creates a matcher that always matches, and `anything(String description)` creates a matcher that always matches and includes a custom description. ```APIDOC ## Static Factory Methods for IsAnything ### `anything()` Creates a matcher that always matches, regardless of the examined object. **Returns:** A `Matcher` that always returns true. ### `anything(String description)` Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified `String`. **Parameters:** * `description` (String) - The description for the matcher. **Returns:** A `Matcher` that always returns true and includes the provided description. ``` -------------------------------- ### IsEqualCompressingWhiteSpace.getString() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Gets the string representation from IsEqualCompressingWhiteSpace. ```APIDOC ## IsEqualCompressingWhiteSpace.getString() ### Description Gets the string. ### Class org.hamcrest.text.IsEqualCompressingWhiteSpace ``` -------------------------------- ### CharSequenceLength.featureValueOf(CharSequence) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for a CharSequence. ```APIDOC ## CharSequenceLength.featureValueOf(CharSequence) ### Description Gets the feature value for a CharSequence. ### Class org.hamcrest.text.CharSequenceLength ``` -------------------------------- ### IsArrayWithSize.featureValueOf(E[]) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for an array. ```APIDOC ## IsArrayWithSize.featureValueOf(E[]) ### Description Gets the feature value for an array. ### Class org.hamcrest.collection.IsArrayWithSize ``` -------------------------------- ### IsAnything() Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Creates an IsAnything matcher. It's recommended to use the `anything()` static factory method instead. ```APIDOC ## IsAnything() ### Description Constructor for the IsAnything matcher. It is best called from the static factory method `anything()`. ### Parameters None ``` -------------------------------- ### IsAnything(String message) Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Creates an IsAnything matcher with a custom description. It's recommended to use the `anything(String)` static factory method instead. ```APIDOC ## IsAnything(String message) ### Description Constructor for the IsAnything matcher that accepts a description string. It is best called from the static factory method `anything(String)`. ### Parameters * **message** (String) - A meaningful string used when describing the matcher. ``` -------------------------------- ### StringStartsWith Constructors Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/StringStartsWith.html Provides constructors for creating StringStartsWith matchers. ```APIDOC ## StringStartsWith(String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Parameters - **prefix** (String) - The expected start of the string. ## StringStartsWith(boolean ignoringCase, String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String, optionally ignoring case. ### Parameters - **ignoringCase** (boolean) - Whether to ignore case when matching. - **prefix** (String) - The expected start of the string. ``` -------------------------------- ### IsIterableWithSize.featureValueOf(Iterable) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for an Iterable. ```APIDOC ## IsIterableWithSize.featureValueOf(Iterable) ### Description Gets the feature value for an Iterable. ### Class org.hamcrest.collection.IsIterableWithSize ``` -------------------------------- ### IsAnything(String) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor for IsAnything, best called from IsAnything.anything(String). ```APIDOC ## IsAnything(String) ### Description Constructor, best called from [`IsAnything.anything(String)`](org/hamcrest/core/IsAnything.html#anything(java.lang.String)). ### Class org.hamcrest.core.IsAnything ``` -------------------------------- ### HasToString.featureValueOf(T) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for an object's toString representation. ```APIDOC ## HasToString.featureValueOf(T) ### Description Gets the feature value for an object's toString representation. ### Class org.hamcrest.object.HasToString ``` -------------------------------- ### IsCollectionWithSize.featureValueOf(Collection) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for a Collection. ```APIDOC ## IsCollectionWithSize.featureValueOf(Collection) ### Description Gets the feature value for a Collection. ### Class org.hamcrest.collection.IsCollectionWithSize ``` -------------------------------- ### SamePropertyValuesAs Class Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/allclasses-index.html A matcher that checks if a given JavaBean has the same property values as an example JavaBean. ```APIDOC ## SamePropertyValuesAs ### Description A matcher that checks if a given bean has the same property values as an example bean. ### Class `org.hamcrest.beans.SamePropertyValuesAs` ``` -------------------------------- ### StringStartsWith Matchers Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/StringStartsWith.html Provides static factory methods for creating StringStartsWith matchers. ```APIDOC ## startsWith(String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String. ### Method Signature `static Matcher startsWith(String prefix)` ### Parameters * **prefix** (String) - The prefix to check for. ## startsWithIgnoringCase(String prefix) ### Description Creates a matcher that matches if the examined String starts with the specified String, ignoring case. ### Method Signature `static Matcher startsWithIgnoringCase(String prefix)` ### Parameters * **prefix** (String) - The prefix to check for, case-insensitively. ``` -------------------------------- ### SamePropertyValuesAs Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/beans/package-summary.html A matcher that checks if a given bean has the same property values as an example bean. ```APIDOC ## SamePropertyValuesAs ### Description A matcher that checks if a given bean has the same property values as an example bean. ### Class `org.hamcrest.beans.SamePropertyValuesAs` ``` -------------------------------- ### Every Matcher Usage Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/Every.html This snippet demonstrates how to use the `everyItem` matcher to verify that all elements in a list match a given condition. ```APIDOC ## Every Matcher ### Description Creates a matcher for `Iterable`s that only matches when a single pass over the examined `Iterable` yields items that are all matched by the specified `itemMatcher`. For example: `assertThat(Arrays.asList("bar", "baz"), everyItem(startsWith("ba"))) ### Type Parameters `U` - the matcher type. ### Parameters * `itemMatcher` - the matcher to apply to every item provided by the examined `Iterable` ### Returns The matcher. ``` -------------------------------- ### StringDescription Constructors Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/StringDescription.html Details on how to instantiate a StringDescription object. ```APIDOC ## StringDescription() ### Description Creates a new description. ### Constructor `public StringDescription()` ``` ```APIDOC ## StringDescription(Appendable out) ### Description Creates a new description using the given appendable. ### Parameters * `out` (Appendable) - the place to append the description. ### Constructor `public StringDescription(Appendable out)` ``` -------------------------------- ### appendList Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Description.html Appends a list of SelfDescribing objects to the description, formatted with a start, separator, and end. ```APIDOC ## appendList ### Description Appends a list of [`SelfDescribing`](SelfDescribing.html "interface in org.hamcrest") objects to the description. ### Parameters * `start` (String) - the prefix. * `separator` (String) - the separator. * `end` (String) - the suffix. * `values` (Iterable) - the values to append. ### Returns (Description) - the update description when displaying the matcher error. ``` -------------------------------- ### IsMapWithSize.featureValueOf(Map) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Method to get the feature value for a Map. ```APIDOC ## IsMapWithSize.featureValueOf(Map) ### Description Gets the feature value for a Map. ### Class org.hamcrest.collection.IsMapWithSize ``` -------------------------------- ### anything(String description) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Static factory method to create an IsAnything matcher with a custom description. ```APIDOC ## anything(String description) ### Description Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified `String`. ### Parameters * **description** (String) - A meaningful `String` used when describing itself. ### Returns * **Matcher** - The `IsAnything` matcher with the provided description. ``` -------------------------------- ### HasToString(Matcher) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor, best called from HasToString.hasToString(String) or HasToString.hasToString(Matcher). ```APIDOC ## HasToString(Matcher) ### Description Constructor, best called from HasToString.hasToString(String) or HasToString.hasToString(Matcher). ### Method Constructor ### Parameters #### Path Parameters - **toStringMatcher** (Matcher) - Required - The matcher for the string representation. ### Class org.hamcrest.object.HasToString ``` -------------------------------- ### anything() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Static factory method to create an IsAnything matcher that always matches. ```APIDOC ## anything() ### Description Creates a matcher that always matches, regardless of the examined object. ### Returns * **Matcher** - The `IsAnything` matcher. ``` -------------------------------- ### notANumber() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/number/IsNaN.html Creates a matcher for `Double`s that matches when an examined double is not a number. For example: `assertThat(Double.NaN, is(notANumber()))`. ```APIDOC ## notANumber() ### Description Creates a matcher of `Double`s that matches when an examined double is not a number. ### Method Signature public static Matcher notANumber() ### Returns The matcher. ``` -------------------------------- ### IsArrayWithSize Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor for IsArrayWithSize, best called via static factory methods. ```APIDOC ## IsArrayWithSize(Matcher) ### Description Constructor for the `IsArrayWithSize` class. It is recommended to use the static factory methods like `emptyArray()`, `arrayWithSize(int)`, or `arrayWithSize(Matcher)` for creating instances. ``` -------------------------------- ### PropertyUtil.getPropertyDescriptor(String, Object) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Static method to get the property descriptor for a given property name on an object. ```APIDOC ## PropertyUtil.getPropertyDescriptor(String, Object) ### Description Returns the description of the property with the provided name on the provided object's interface. ### Class org.hamcrest.beans.PropertyUtil ``` -------------------------------- ### StringDescription Constructors Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/StringDescription.html Provides details on how to instantiate a StringDescription object. ```APIDOC ## StringDescription() ### Description Creates a new, empty description. ### Constructor `StringDescription()` ``` ```APIDOC ## StringDescription(Appendable out) ### Description Creates a new description that appends to the provided `Appendable`. ### Constructor `StringDescription(Appendable out)` ``` -------------------------------- ### CustomMatcher Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomMatcher.html Initializes a new instance of the CustomMatcher class with a description. ```APIDOC ## CustomMatcher(String description) ### Description Constructor for CustomMatcher. ### Parameters #### Path Parameters - **description** (String) - Required - A description of the matcher. ``` -------------------------------- ### appendValueList (Iterable) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/BaseDescription.html Appends a list of values from an Iterable to the description, with specified start, separator, and end strings. ```APIDOC ## appendValueList (Iterable) ### Description Appends a list of values to the description. ### Type Parameters * **T** - The type of the values in the iterable. ### Parameters * **start** (`String`) - The prefix string for the list. * **separator** (`String`) - The string to separate values. * **end** (`String`) - The suffix string for the list. * **values** (`Iterable`) - The iterable collection of values to append. ### Returns * (`Description`) - The updated description for displaying matcher errors. ``` -------------------------------- ### AllOf Matcher Usage Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/AllOf.html Demonstrates how to use the allOf matcher to assert that an object satisfies multiple conditions. ```APIDOC ## allOf Creates a matcher that matches if the examined object matches **ALL** of the specified matchers. For example: ```java assertThat("myValue", allOf(startsWith("my"), containsString("Val"))) ``` ### Method Signature ```java public static Matcher allOf(Matcher... matchers) ``` ### Parameters - `matchers` (Matcher...) - An array of matchers. All provided matchers must pass for the composite matcher to succeed. ``` -------------------------------- ### anExistingDirectory() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/io/FileMatchers.html Creates a matcher that checks if the file system entry exists and is a directory. ```APIDOC ## anExistingDirectory() ### Description A matcher that checks if a directory exists. ### Method static Matcher ``` -------------------------------- ### appendList Method (Varargs) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Description.NullDescription.html Appends a list of SelfDescribing values to the description, formatted with start, separator, and end strings. ```APIDOC ## appendList public Description appendList(String start, String separator, String end, T... values) ### Description Appends a list of values to the description. ### Parameters * **start** (String) - The string to prepend to the list. * **separator** (String) - The string to use between elements in the list. * **end** (String) - The string to append to the end of the list. * **values** (T...) - The varargs array of values to append. ``` -------------------------------- ### BaseMatcher() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Default constructor for BaseMatcher. ```APIDOC ## BaseMatcher() ### Description Default constructor for BaseMatcher. ### Method Constructor ### Class org.hamcrest.BaseMatcher ``` -------------------------------- ### appendList Method (Iterable) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Description.NullDescription.html Appends a list of SelfDescribing values to the description, formatted with start, separator, and end strings. ```APIDOC ## appendList public Description appendList(String start, String separator, String end, Iterable values) ### Description Appends a list of values to the description. ### Parameters * **start** (String) - The string to prepend to the list. * **separator** (String) - The string to use between elements in the list. * **end** (String) - The string to append to the end of the list. * **values** (Iterable) - The iterable of values to append. ``` -------------------------------- ### anything(String description) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Matchers.html Creates a matcher that always matches and describes itself with a given string. ```APIDOC ## anything ### Description Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified `String`. ### Method Signature `public static Matcher anything(String description)` ### Parameters * `description` (String) - a meaningful `String` used when describing itself. ### Returns * Matcher - The matcher. ``` -------------------------------- ### Matcher Creation Methods Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/io/FileMatchers.html Static methods for creating Hamcrest Matchers for File objects. ```APIDOC ## Matcher Creation Methods ### anExistingDirectory A matcher that checks if a directory exists. Returns: the file matcher ### anExistingFileOrDirectory A matcher that checks if a file or directory exists. Returns: the file matcher ### anExistingFile A matcher that checks if a file exists. Returns: the file matcher ### aReadableFile A matcher that checks if a file is readable. Returns: the file matcher ### aWritableFile A matcher that checks if a directory is writable. Returns: the file matcher ### aFileWithSize(long size) A matcher that checks if a file has a specific size. Parameters: `size` - the expected size Returns: the file matcher ### aFileWithSize(Matcher expected) A matcher that checks if a file size matches an expected size. Parameters: `expected` - matcher for the expected size Returns: the file matcher ### aFileNamed(Matcher expected) A matcher that checks if a file name matches an expected name. Parameters: `expected` - matcher for the expected name ``` -------------------------------- ### Creating a CustomTypeSafeMatcher for Non-Empty Strings Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomTypeSafeMatcher.html Example of creating a custom matcher for strings that are not empty. This matcher extends CustomTypeSafeMatcher and implements `matchesSafely` and `describeMismatchSafely`. ```java Matcher aNonEmptyString = new CustomTypeSafeMatcher("a non empty string") { public boolean matchesSafely(String string) { return !string.isEmpty(); } public void describeMismatchSafely(String string, Description mismatchDescription) { mismatchDescription.appendText("was empty"); } }; ``` -------------------------------- ### Failure Message Example for NaN Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/tutorial.md Illustrates the failure message generated when the custom 'notANumber' matcher fails. This helps in diagnosing assertion errors. ```java assertThat(1.0, is(notANumber())); // fails with the message java.lang.AssertionError: Expected: is not a number got : <1.0> ``` -------------------------------- ### BaseDescription() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Default constructor for BaseDescription. ```APIDOC ## BaseDescription() ### Description Default constructor for BaseDescription. ### Method Constructor ### Class org.hamcrest.BaseDescription ``` -------------------------------- ### appendValueList (Varargs) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/BaseDescription.html Appends a list of values to the description, formatted with a start, separator, and end string, using varargs. This method is part of the Description interface. ```APIDOC ## appendValueList(String start, String separator, String end, Object... values) ### Description Appends a list of values to the description. ### Parameters * **start** (String) - The string to prepend to the list. * **separator** (String) - The string to insert between values. * **end** (String) - The string to append to the list. * **values** (Object...) - The array of values to append. ``` -------------------------------- ### Description.NullDescription Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Description.NullDescription.html Constructs a new NullDescription. This description consumes input but performs no action. ```APIDOC ## NullDescription() ### Description Constructor. ### Method `NullDescription()` ``` -------------------------------- ### Example Usage of IsNaN Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/number/IsNaN.html Demonstrates how to use the `is(notANumber())` matcher in an `assertThat` statement to verify if a Double value is NaN. Ensure `org.hamcrest.MatcherAssert.assertThat` and `org.hamcrest.Matchers.is` are imported. ```java assertThat(Double.NaN, is(notANumber())) ``` -------------------------------- ### NullDescription Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Description.NullDescription.html Initializes a new instance of the NullDescription class. ```APIDOC ## NullDescription public NullDescription() Constructor. ``` -------------------------------- ### Git Commands for Version Update and Tagging Source: https://github.com/hamcrest/javahamcrest/blob/master/RELEASING.md Use these commands to commit version changes, tag the release, and push to GitHub. Example shown for version 3.0. ```shell git add build.gradle git commit -m "Version 3.0" git tag v3.0 git push origin --tags ``` -------------------------------- ### CombinableBothMatcher Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/CombinableMatcher.CombinableBothMatcher.html Initializes a CombinableBothMatcher with a single matcher. It's recommended to use the CombinableMatcher.both(Matcher) factory method for creating instances. ```APIDOC ## CombinableBothMatcher Constructor ### Description Initializes a CombinableBothMatcher with a single matcher. This constructor is best called from `CombinableMatcher.both(Matcher)`. ### Parameters * **matcher** (Matcher) - The first matcher to be combined. ``` -------------------------------- ### Custom Matcher for NaN Check Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/tutorial.md Example of writing a custom Hamcrest matcher to check if a double value is NaN (Not a Number). This is useful for encapsulating repeated test logic. ```java @Test public void testSquareRootOfMinusOneIsNotANumber() { assertThat(Math.sqrt(-1), is(notANumber())); } ``` -------------------------------- ### Instance Methods Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsNull.html Instance methods for the IsNull matcher, including describing the matcher and evaluating matches. ```APIDOC ## describeTo(org.hamcrest.Description description) ### Description Generates a description of the object. ### Method Signature `void describeTo(org.hamcrest.Description description)` ``` ```APIDOC ## matches(java.lang.Object o) ### Description Evaluates the matcher for argument item. ### Method Signature `boolean matches(java.lang.Object o)` ``` -------------------------------- ### Create Any Type Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Use `any` to create a matcher that checks if an object is an instance of a specified type using `Class.isInstance()`. This is useful for conforming generics, for example, in JMock clauses. ```java assertThat(new Canoe(), any(Canoe.class)); ``` -------------------------------- ### describeTo Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/Every.html Generates a description of the Every matcher. ```APIDOC ## describeTo public void describeTo(Description description) ### Description Generates a description of the object. The description may be part of a description of a larger object of which this is just a component, so it should be worded appropriately. ### Parameters * `description` (Description) - The description to be built or appended to. ``` -------------------------------- ### HasXPath Constructors Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/xml/HasXPath.html Provides details on how to instantiate the HasXPath matcher with or without a NamespaceContext. ```APIDOC ## HasXPath(String xPathExpression, Matcher valueMatcher) ### Description Constructor for creating a HasXPath matcher. It's recommended to use the static factory methods. ### Parameters * `xPathExpression` (String) - The XPath expression to evaluate. * `valueMatcher` (Matcher) - A matcher for the expected string value of the selected node. ## HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher valueMatcher) ### Description Constructor for creating a HasXPath matcher with a specified NamespaceContext. It's recommended to use the static factory methods. ### Parameters * `xPathExpression` (String) - The XPath expression to evaluate. * `namespaceContext` (NamespaceContext) - The NamespaceContext to use for resolving namespace prefixes in the XPath. * `valueMatcher` (Matcher) - A matcher for the expected string value of the selected node. ``` -------------------------------- ### Match Collection Size with a Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsCollectionWithSize.html Use this matcher when the expected size of a collection needs to satisfy a condition defined by another matcher. For example, checking if the size is equal to a specific value. ```java assertThat(Arrays.asList("foo", "bar"), hasSize(equalTo(2))) ``` -------------------------------- ### File Matchers for java.io.File Source: https://context7.com/hamcrest/javahamcrest/llms.txt Use these matchers to assert properties of java.io.File objects such as existence, readability, writability, size, and name patterns. Ensure java.io.File is imported. ```java import java.io.File; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.io.FileMatchers.*; @Test public void fileMatchers() throws Exception { File tmp = File.createTempFile("hamcrest-test", ".txt"); tmp.deleteOnExit(); assertThat(tmp, anExistingFile()); assertThat(tmp, aReadableFile()); assertThat(tmp, aWritableFile()); assertThat(tmp, not(anExistingDirectory())); // Size check assertThat(tmp, aFileWithSize(0L)); assertThat(tmp, aFileWithSize(lessThanOrEqualTo(1024L))); // Name and path checks assertThat(tmp, aFileNamed(startsWith("hamcrest-test"))); assertThat(tmp, aFileWithAbsolutePath(containsString("hamcrest-test"))); File dir = tmp.getParentFile(); assertThat(dir, anExistingDirectory()); assertThat(dir, anExistingFileOrDirectory()); } ``` -------------------------------- ### Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/MatchesPattern.html Initializes a MatchesPattern matcher with a pre-compiled Pattern. This constructor is typically used internally and users should prefer the static factory methods. ```APIDOC ## MatchesPattern(Pattern pattern) ### Description Constructor, best called from `matchesPattern(String)` or `matchesPattern(Pattern)`. ### Constructor Signature ```java MatchesPattern(Pattern pattern) ``` ### Parameters * **pattern** (Pattern) - The compiled regular expression Pattern to use for matching. ``` -------------------------------- ### aWritableFile() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/io/FileMatchers.html Creates a matcher that checks if the file system entry exists and is writable by the application. ```APIDOC ## aWritableFile() ### Description A matcher that checks if a directory is writable. ### Method static Matcher ``` -------------------------------- ### Gradle Upgrade Example for Hamcrest Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/distributables.md When upgrading from Hamcrest 1.x, explicitly declare dependencies on 'hamcrest' and 'hamcrest-library' to ensure correct version conflict resolution, especially in projects that depend on JUnit 4. ```gradle apply plugin: 'java' dependencies { testImplementation 'org.hamcrest:hamcrest:3.0' testImplementation 'org.hamcrest:hamcrest-library:3.0' testImplementation 'junit:junit:4.13.2' } ``` -------------------------------- ### matching(Matcher, String) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Applies the given matcher as the final step in a sequence, with an associated description. ```APIDOC ## matching(Matcher, String) ### Description Applies the provided matcher as the final step in a sequence of conditions, and associates a descriptive string with it. This aids in understanding the purpose of the matcher in the sequence. ### Method `matching(Matcher matcher, String description)` ### Class `org.hamcrest.Condition` ``` -------------------------------- ### Checking Person Name with HasPropertyWithValue Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/beans/HasPropertyWithValue.html This example demonstrates how to use hasProperty to assert that a generated Person object has the name "Iain". It's used within a mock object's expectation to verify the arguments passed to a method. ```java Mock personGenListenerMock = mock(PersonGenerationListener.class); personGenListenerMock.expects(once()).method("personGenerated").with(and(isA(Person.class), hasProperty("Name", eq("Iain")))); PersonGenerationListener listener = (PersonGenerationListener)personGenListenerMock.proxy(); ``` -------------------------------- ### iterableWithSize(int size) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsIterableWithSize.html Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that is equal to the specified size argument. For example: assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2)) ```APIDOC ## iterableWithSize(int size) ### Description Creates a matcher for [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang")s that matches when a single pass over the examined [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang") yields an item count that is equal to the specified `size` argument. For example: assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2)) ### Parameters * `size` - the number of items that should be yielded by an examined [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang") ### Returns The matcher. ``` -------------------------------- ### iterableWithSize(Matcher sizeMatcher) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/IsIterableWithSize.html Creates a matcher for Iterables that matches when a single pass over the examined Iterable yields an item count that satisfies the specified matcher. For example: assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2))) ```APIDOC ## iterableWithSize(Matcher sizeMatcher) ### Description Creates a matcher for [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang")s that matches when a single pass over the examined [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang") yields an item count that satisfies the specified matcher. For example: assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2))) ### Parameters * `sizeMatcher` - a matcher for the number of items that should be yielded by an examined [`Iterable`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Iterable.html "class or interface in java.lang") ### Returns The matcher. ``` -------------------------------- ### IsAnything Matcher Functionality Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsAnything.html Details the core functionality of the IsAnything matcher, including its constructor and the `matches` method. ```APIDOC ## IsAnything Class Details ### Constructor `IsAnything()` Constructor, best called from `anything()`. `IsAnything(String message)` Constructor, best called from `anything(String)`. ### Method `matches(Object o)` Evaluates the matcher against an input object. **Parameters:** * `o` (Object) - The object to match. **Returns:** `true`. This matcher always returns true, irrespective of the input object. ``` -------------------------------- ### anExistingFile() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/io/FileMatchers.html Creates a matcher that checks if the file system entry exists and is a regular file. ```APIDOC ## anExistingFile() ### Description A matcher that checks if a file exists. ### Method static Matcher ``` -------------------------------- ### IsEqualIgnoringCase(String string) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/IsEqualIgnoringCase.html Constructor for IsEqualIgnoringCase. It is recommended to use the static factory method equalToIgnoringCase(String) instead. ```APIDOC ## IsEqualIgnoringCase(String string) ### Description Constructor for the IsEqualIgnoringCase matcher. This constructor is intended for internal use and it is recommended to use the static factory method `equalToIgnoringCase(String)`. ### Method Signature `public IsEqualIgnoringCase(String string)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```java // Direct constructor usage (not recommended) import org.hamcrest.Matcher; import org.hamcrest.text.IsEqualIgnoringCase; Matcher matcher = new IsEqualIgnoringCase("expected"); ``` ### Response #### Success Response - Creates an instance of `IsEqualIgnoringCase`. #### Response Example - N/A ``` -------------------------------- ### describedAs Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/DescribedAs.html Wraps an existing matcher, overriding its description with a custom one. All other functions are delegated to the decorated matcher. ```APIDOC ## describedAs ### Description Wraps an existing matcher, overriding its description with that specified. All other functions are delegated to the decorated matcher, including its mismatch description. For example: describedAs("a big decimal equal to %0", equalTo(myBigDecimal), myBigDecimal.toPlainString()) ### Method Signature public static Matcher describedAs(String descriptionTemplate, Matcher matcher, Object... values) ### Parameters * `descriptionTemplate` (String) - The new description for the wrapped matcher. * `matcher` (Matcher) - The matcher to wrap. * `values` (Object...) - Optional values to insert into the tokenised description. ### Returns * Matcher - The matcher with the overridden description. ``` -------------------------------- ### theInstance Static Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsSame.html Creates a matcher that matches only when the examined object is the same instance as the specified target object. ```APIDOC ## theInstance Static Method ### Description Creates a matcher that matches only when the examined object is the same instance as the specified target object. ### Type Parameters * **T** - the matcher type. ### Parameters * **target** (T) - the target instance against which others should be assessed ### Returns * Matcher - The matcher. ``` -------------------------------- ### Matcher: anything(String description) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Matchers.html Creates a matcher that always matches and describes itself with the provided string. Useful for adding context to always-matching assertions. ```java anything("a description") ``` -------------------------------- ### anything(String) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified String. Available in IsAnything, CoreMatchers, and Matchers classes. ```APIDOC ## anything(String) ### Description Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified [`String`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/String.html "class or interface in java.lang"). ### Method Static factory method ### Classes org.hamcrest.core.IsAnything, org.hamcrest.CoreMatchers, org.hamcrest.Matchers ``` -------------------------------- ### DescribedAs Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Wraps an existing matcher to override its description, providing custom feedback. ```APIDOC ## Static Method: describedAs(String description, Matcher matcher, Object... args) ### Description Wraps an existing matcher, overriding its description with that specified. ### Class org.hamcrest.core.DescribedAs ``` ```APIDOC ## Static Method: describedAs(String description, Matcher matcher, Object... args) ### Description Wraps an existing matcher, overriding its description with that specified. ### Class org.hamcrest.CoreMatchers ``` ```APIDOC ## Static Method: describedAs(String description, Matcher matcher, Object... args) ### Description Wraps an existing matcher, overriding its description with that specified. ### Class org.hamcrest.Matchers ``` ```APIDOC ## Class: DescribedAs ### Description Provides a custom description to another matcher. ### Package org.hamcrest.core ``` ```APIDOC ## Constructor: DescribedAs(String description, Matcher matcher, Object[] args) ### Description Constructor, best called from [`DescribedAs.describedAs(String, Matcher, Object...)`](org/hamcrest/core/DescribedAs.html#describedAs(java.lang.String,org.hamcrest.Matcher,java.lang.Object...)). ### Class org.hamcrest.core.DescribedAs ``` -------------------------------- ### anything Matcher with Description Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Use `anything(String description)` to create a matcher that always matches but provides a custom description. This can improve test failure messages. ```java anything("a meaningful description") ``` -------------------------------- ### describeTo Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsEqual.html Generates a description of the matcher. ```APIDOC ## describeTo Method ### Description Generates a description of the matcher. This description may be part of a larger description, so it should be worded appropriately. ### Parameters * `description` (Description) - The description to be built or appended to. ``` -------------------------------- ### IsEqualCompressingWhiteSpace Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/IsEqualCompressingWhiteSpace.html Constructor for IsEqualCompressingWhiteSpace, best called from equalToCompressingWhiteSpace(String). ```APIDOC ## IsEqualCompressingWhiteSpace(String string) ### Description Constructor, best called from [`equalToCompressingWhiteSpace(String)`](#equalToCompressingWhiteSpace\(java.lang.String\)). ### Constructor Signature `IsEqualCompressingWhiteSpace(String string)` ``` -------------------------------- ### HasProperty(String propertyName) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor for HasProperty, best called from HasProperty.hasProperty(String). ```APIDOC ## HasProperty(String propertyName) ### Description Constructor, best called from [`HasProperty.hasProperty(String)`](org/hamcrest/beans/HasProperty.html#hasProperty\(java.lang.String\)). ### Constructor For class org.hamcrest.beans.HasProperty ``` -------------------------------- ### IsInstanceOf Core Methods Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/core/IsInstanceOf.html Provides information on the core methods used by IsInstanceOf matchers. ```APIDOC ## Method Summary ### `describeTo(Description description)` Generates a description of the object. ### `matches(Object item, Description mismatch)` Evaluates the matcher for argument item. ``` -------------------------------- ### HasPropertyWithValue(String propertyName, Matcher valueMatcher, String propertyPath) Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/index-all.html Constructor for HasPropertyWithValue, best called from HasPropertyWithValue.hasProperty(String, Matcher) or HasPropertyWithValue.hasPropertyAtPath(String, Matcher). ```APIDOC ## HasPropertyWithValue(String propertyName, Matcher valueMatcher, String propertyPath) ### Description Constructor, best called from [`HasPropertyWithValue.hasProperty(String, Matcher)`](org/hamcrest/beans/HasPropertyWithValue.html#hasProperty\(java.lang.String,org.hamcrest.Matcher\)) or [`HasPropertyWithValue.hasPropertyAtPath(String, Matcher)`](org/hamcrest/beans/HasPropertyWithValue.html#hasPropertyAtPath\(java.lang.String,org.hamcrest.Matcher\)). ### Constructor For class org.hamcrest.beans.HasPropertyWithValue ``` -------------------------------- ### Create Empty String Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/IsEmptyString.html Creates a matcher that asserts a String has zero length. This is the recommended way to check for empty strings. ```java public static Matcher emptyString() { return is(emptyString()); } ``` -------------------------------- ### anExistingFileOrDirectory() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/io/FileMatchers.html Creates a matcher that checks if the file system entry exists (either a file or a directory). ```APIDOC ## anExistingFileOrDirectory() ### Description A matcher that checks if a file or directory exists. ### Method static Matcher ``` -------------------------------- ### anything Matcher Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CoreMatchers.html Creates a matcher that always matches, regardless of the examined object. Can optionally include a description. ```APIDOC ## anything ### Description Creates a matcher that always matches, regardless of the examined object. ### Method Signature `static Matcher anything()` `static Matcher anything(String description)` ``` -------------------------------- ### IsCloseTo Constructor Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/number/IsCloseTo.html Initializes a new instance of the IsCloseTo class. It's recommended to use the `closeTo` static factory method for creating instances. ```APIDOC ## IsCloseTo Constructor ### Description Initializes a new instance of the `IsCloseTo` class. ### Parameters * **value** (double) - The expected value. * **error** (double) - The acceptable difference from the expected value. ``` -------------------------------- ### anything Matchers Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/Matchers.html Creates a matcher that always matches, regardless of the examined object. Can optionally take a description string. ```APIDOC ## anything ### Description Creates a matcher that always matches, regardless of the examined object. ### Method Signature `static Matcher anything()` ### Description Creates a matcher that always matches, regardless of the examined object, but describes itself with the specified String. ### Method Signature `static Matcher anything(String description)` ``` -------------------------------- ### describeTo Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/CustomMatcher.html Generates a description of the matcher object. ```APIDOC ## describeTo(Description description) ### Description Generates a description of the object. This method is part of the `SelfDescribing` interface. ### Parameters #### Path Parameters - **description** (Description) - Required - The description to append to. ``` -------------------------------- ### BaseMatcher Constructors Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/BaseMatcher.html Provides details on the constructors available for the BaseMatcher class. ```APIDOC ## Constructor Summary ### BaseMatcher() Default constructor. ``` -------------------------------- ### describeTo Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/collection/HasItemInArray.html Generates a description of the HasItemInArray matcher. ```APIDOC ## void describeTo(Description description) ### Description Generates a description of the object. ### Parameters * **description** (Description) - The description to append the matcher's description to. ``` -------------------------------- ### emptyString() Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/text/IsEmptyString.html Creates a matcher that matches an empty string (zero length). This is the recommended method to use. ```APIDOC ## emptyString() ### Description Creates a matcher of `String` that matches when the examined string has zero length. ### Method Signature `public static Matcher emptyString()` ### Example Usage `assertThat("", is(emptyString()))` ### Returns The matcher for an empty string. ``` -------------------------------- ### toString() Method Source: https://github.com/hamcrest/javahamcrest/blob/master/docs/javadoc/3.0/org/hamcrest/StringDescription.html Retrieves the complete description as a String. This method is an override of the Object.toString() method. ```APIDOC ## toString ### Description Returns the description as a string. ### Method ```java public String toString() ``` ### Overrides `Object.toString()` ```