Class AbstractAssertion

java.lang.Object
pl.pojo.tester.api.assertion.AbstractAssertion

public abstract class AbstractAssertion extends Object
This is abstract class for all assertion classes.

For more documentation, please refer POJO-TESTER User Guide documentation

Since:
0.1.0
  • Constructor Details

    • AbstractAssertion

      public AbstractAssertion()
  • Method Details

    • using

      public AbstractAssertion using(AbstractFieldValueChanger abstractFieldValueChanger)
      Specifies what field values changer will be used for testing.
      Parameters:
      abstractFieldValueChanger - field values changer
      Returns:
      itself
      See Also:
    • thoroughly

      public AbstractAssertion thoroughly()
      Specifies generation of O(2^N) test objects for N fields. A class with more than ThoroughFieldPermutator.MAX_FIELDS fields, including a nested one, uses the linear strategy instead. A warning names that class.
      Returns:
      itself
    • quickly

      public AbstractAssertion quickly()
      Specifies generation of O(N) test objects for N fields.
      Returns:
      itself
    • changingFinalFields

      public AbstractAssertion changingFinalFields()
      Also assigns new values to final fields when proving that equals, hashCode and toString see them. Off by default: those fields keep the value they were constructed with. Turn this on only when the class under test has to be checked through a final field and the JDK can still change it.
      Returns:
      itself
    • withFieldPrefix

      public AbstractAssertion withFieldPrefix(String prefix)
      Strips a prefix from field names before matching getters and setters. withFieldPrefix("m") maps mName to getName. withFieldPrefix("m_") maps m_name to getName. A field that does not start with the prefix is matched as written.
      Parameters:
      prefix - prefix used on fields, never blank
      Returns:
      itself
    • usingFluentAccessors

      public AbstractAssertion usingFluentAccessors()
      Also accepts a getter or setter whose name is the field name. That is the shape of Lombok @Accessors(fluent = true). Off by default, so a method that happens to share a field's name is not a getter.
      Returns:
      itself
    • allowingSameHashCodeForUnequalObjects

      public AbstractAssertion allowingSameHashCodeForUnequalObjects()
      Skips the check that unequal objects have different hash codes. Object.hashCode() does not require that. Off by default, because a collision here usually means a field was left out of hashCode.
      Returns:
      itself
    • testing

      public AbstractAssertion testing(Method... methods)
      Specifies what tests will be performed.
      Parameters:
      methods - methods to test
      Returns:
      itself
      See Also:
    • testing

      public AbstractAssertion testing(Method method)
      Specifies what test will be performed.
      Parameters:
      method - method to test
      Returns:
      itself
      See Also:
    • areWellImplemented

      public void areWellImplemented()
      Performs specified tests on classes using declared field value changer.
      See Also:
    • create

      public AbstractAssertion create(String qualifiedClassName, Object[] constructorParameters, Class<?>[] constructorParameterTypes)
      Indicates, that class should be constructed using given constructor parameters. Constructor will be selected based on constructor parameter's types.
      Parameters:
      qualifiedClassName - class to instantiate
      constructorParameters - constructor parameters
      constructorParameterTypes - constructor parameter's types
      Returns:
      itself
      See Also:
    • create

      public AbstractAssertion create(String qualifiedClassName, ConstructorParameters constructorParameters)
      Indicates, that class should be constructed using given constructor parameters. Constructor will be selected based on constructor parameter's types.
      Parameters:
      qualifiedClassName - class to instantiate
      constructorParameters - constructor parameters
      Returns:
      itself
      See Also:
    • create

      public AbstractAssertion create(Class<?> clazz, Object[] constructorParameters, Class<?>[] constructorParameterTypes)
      Indicates, that class should be constructed using given constructor parameters. Constructor will be selected based on constructor parameter's types.
      Parameters:
      clazz - class to instantiate
      constructorParameters - constructor parameters
      constructorParameterTypes - constructor parameter's types
      Returns:
      itself
      See Also:
    • create

      public AbstractAssertion create(Class<?> clazz, ConstructorParameters constructorParameters)
      Indicates, that class should be constructed using given constructor parameters. Constructor will be selected based on constructor parameter's types.
      Parameters:
      clazz - class to instantiate
      constructorParameters - constructor parameters
      Returns:
      itself
      See Also:
    • create

      public AbstractAssertion create(Class<?> clazz, Supplier<?> supplier)
      Instantiates clazz with supplier instead of the built-in instantiators. The supplier must return a new instance on every call. Use this for builders and for constructors that reject the values the library would otherwise generate.
      Parameters:
      clazz - class to instantiate
      supplier - creates instances of clazz
      Returns:
      itself
    • runAssertions

      protected abstract void runAssertions()
    • logTestersAndClasses

      protected void logTestersAndClasses(org.slf4j.Logger logger, ClassAndFieldPredicatePair... classAndFieldPredicatePairs)