Class Verifiers

java.lang.Object
io.github.cjstehno.testthings.Verifiers

public final class Verifiers extends Object
Some utility methods useful for verifying common functionality of objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    verifyEqualsAndHashCode(Object instanceA, Object instanceB)
    Used to verify that the equals(Object) and hashCode() methods return values that meet with the standard contract for those methods.
    static void
    An alias to the verifyEqualsAndHashCode(Object,Object) method, calling the provided Supplier<Object> for each.
    static void
    verifyToString(String expected, Object obj)
    Used to verify that the toString() method of the object provided by the matches the given string.
    static void
    verifyToString(String expected, Supplier<Object> supplier)
    Used to verify that the toString() method of the object provided by the Supplier<Object> matches the expected String.
    static void
    verifyToString(org.hamcrest.Matcher<String> matcher, Object obj)
    Used to verify that the toString() method of the object provided by the matches the given Matcher.
    static void
    verifyToString(org.hamcrest.Matcher<String> matcher, Supplier<Object> supplier)
    Used to verify that the toString() method of the object provided by the Supplier<Object> matches the given Matcher.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Verifiers

      public Verifiers()
  • Method Details

    • verifyEqualsAndHashCode

      public static void verifyEqualsAndHashCode(Supplier<Object> supplier)
      An alias to the verifyEqualsAndHashCode(Object,Object) method, calling the provided Supplier<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

      public static void verifyEqualsAndHashCode(Object instanceA, Object instanceB)
      Used to verify that the equals(Object) and hashCode() 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 instance
      instanceB - the second instance
    • verifyToString

      public static void verifyToString(String expected, Supplier<Object> supplier)
      Used to verify that the toString() method of the object provided by the Supplier<Object> matches the expected String.
      Parameters:
      expected - the expected string
      supplier - a supplier that will be used to generate the object to be tested
    • verifyToString

      public static void verifyToString(org.hamcrest.Matcher<String> matcher, Supplier<Object> supplier)
      Used to verify that the toString() method of the object provided by the Supplier<Object> matches the given Matcher.
      Parameters:
      matcher - the Matcher for the generated string
      supplier - a supplier that will be used to generate the object to be tested
    • verifyToString

      public static void verifyToString(org.hamcrest.Matcher<String> matcher, Object obj)
      Used to verify that the toString() method of the object provided by the matches the given Matcher.
      Parameters:
      matcher - the Matcher for the generated string
      obj - the object to be tested
    • verifyToString

      public static void verifyToString(String expected, Object obj)
      Used to verify that the toString() method of the object provided by the matches the given string.
      Parameters:
      expected - the expected string value
      obj - the object to be tested