Class BeanAssert


  • public final class BeanAssert
    extends Object
    Assertion class to compare beans.

    This class fulfils a similar role to other assertion libraries in testing code. It should generally be statically imported.

    • Method Detail

      • assertBeanEquals

        public static void assertBeanEquals​(Bean expected,
                                            Bean actual)
        Asserts that two beans are equal, providing a better error message.
        Parameters:
        expected - the expected value, not null
        actual - the actual value, not null
      • assertBeanEquals

        public static void assertBeanEquals​(Bean expected,
                                            Bean actual,
                                            double tolerance)
        Asserts that two beans are equal, providing a better error message.

        Note that specifying a tolerance can mean that two beans compare as not equal using Object.equals(Object) but equal using this method, because the standard equals method has no tolerance.

        Parameters:
        expected - the expected value, not null
        actual - the actual value, not null
        tolerance - the tolerance to use for double and float
      • assertBeanEquals

        public static void assertBeanEquals​(String baseMsg,
                                            Bean expected,
                                            Bean actual)
        Asserts that two beans are equal, providing a better error message.
        Parameters:
        baseMsg - the message to use in any error, null uses default message
        expected - the expected value, not null
        actual - the actual value, not null
      • assertBeanEquals

        public static void assertBeanEquals​(String baseMsg,
                                            Bean expected,
                                            Bean actual,
                                            double tolerance)
        Asserts that two beans are equal, providing a better error message.

        Note that specifying a tolerance can mean that two beans compare as not equal using Object.equals(Object) but equal using this method, because the standard equals method has no tolerance.

        Parameters:
        baseMsg - the message to use in any error, null uses default message
        expected - the expected value, not null
        actual - the actual value, not null
        tolerance - the tolerance to use for double and float
      • assertBeanEqualsFullDetail

        public static void assertBeanEqualsFullDetail​(Bean expected,
                                                      Bean actual)
        Asserts that two beans are equal, providing a better error message.
        Parameters:
        expected - the expected value, not null
        actual - the actual value, not null
      • assertBeanEqualsFullDetail

        public static void assertBeanEqualsFullDetail​(Bean expected,
                                                      Bean actual,
                                                      double tolerance)
        Asserts that two beans are equal, providing a better error message.

        Note that specifying a tolerance can mean that two beans compare as not equal using Object.equals(Object) but equal using this method, because the standard equals method has no tolerance.

        Parameters:
        expected - the expected value, not null
        actual - the actual value, not null
        tolerance - the tolerance to use for double and float
      • assertBeanEqualsFullDetail

        public static void assertBeanEqualsFullDetail​(String baseMsg,
                                                      Bean expected,
                                                      Bean actual)
        Asserts that two beans are equal, providing a better error message, with an unlimited number of errors reported.
        Parameters:
        baseMsg - the message to use in any error, null uses default message
        expected - the expected value, not null
        actual - the actual value, not null
      • assertBeanEqualsFullDetail

        public static void assertBeanEqualsFullDetail​(String baseMsg,
                                                      Bean expected,
                                                      Bean actual,
                                                      double tolerance)
        Asserts that two beans are equal, providing a better error message, with an unlimited number of errors reported.

        Note that specifying a tolerance can mean that two beans compare as not equal using Object.equals(Object) but equal using this method, because the standard equals method has no tolerance.

        Parameters:
        baseMsg - the message to use in any error, null uses default message
        expected - the expected value, not null
        actual - the actual value, not null
        tolerance - the tolerance to use for double and float