Package io.github.cjstehno.testthings
Class Verifiers
java.lang.Object
io.github.cjstehno.testthings.Verifiers
Some utility methods useful for verifying common functionality of objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidverifyEqualsAndHashCode(Object instanceA, Object instanceB) Used to verify that theequals(Object)andhashCode()methods return values that meet with the standard contract for those methods.static voidverifyEqualsAndHashCode(Supplier<Object> supplier) An alias to theverifyEqualsAndHashCode(Object,Object)method, calling the providedSupplier<Object>for each.static voidverifyToString(String expected, Object obj) Used to verify that thetoString()method of the object provided by the matches the given string.static voidverifyToString(String expected, Supplier<Object> supplier) Used to verify that thetoString()method of the object provided by theSupplier<Object>matches the expected String.static voidverifyToString(org.hamcrest.Matcher<String> matcher, Object obj) Used to verify that thetoString()method of the object provided by the matches the given Matcher.static voidverifyToString(org.hamcrest.Matcher<String> matcher, Supplier<Object> supplier) Used to verify that thetoString()method of the object provided by theSupplier<Object>matches the given Matcher.
-
Constructor Details
-
Verifiers
public Verifiers()
-
-
Method Details
-
verifyEqualsAndHashCode
An alias to theverifyEqualsAndHashCode(Object,Object)method, calling the providedSupplier<Object>for each. See that method description for details.- Parameters:
supplier- a supplier that will be called twice to provide the objects to be used in the test
-
verifyEqualsAndHashCode
Used to verify that theequals(Object)andhashCode()methods return values that meet with the standard contract for those methods. The two instances provided should be equivalent, but not the same instance.- Parameters:
instanceA- the first instanceinstanceB- the second instance
-
verifyToString
Used to verify that thetoString()method of the object provided by theSupplier<Object>matches the expected String.- Parameters:
expected- the expected stringsupplier- a supplier that will be used to generate the object to be tested
-
verifyToString
Used to verify that thetoString()method of the object provided by theSupplier<Object>matches the given Matcher.- Parameters:
matcher- the Matcher for the generated stringsupplier- a supplier that will be used to generate the object to be tested
-
verifyToString
Used to verify that thetoString()method of the object provided by the matches the given Matcher.- Parameters:
matcher- the Matcher for the generated stringobj- the object to be tested
-
verifyToString
Used to verify that thetoString()method of the object provided by the matches the given string.- Parameters:
expected- the expected string valueobj- the object to be tested
-