Package pl.pojo.tester.api.assertion
Class AbstractAssertion
java.lang.Object
pl.pojo.tester.api.assertion.AbstractAssertion
This is abstract class for all assertion classes.
For more documentation, please refer POJO-TESTER User Guide documentation
- Since:
- 0.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSkips the check that unequal objects have different hash codes.voidPerforms specified tests on classes using declared field value changer.Also assigns new values tofinalfields when proving thatequals,hashCodeandtoStringsee them.Indicates, that class should be constructed using given constructor parameters.Instantiatesclazzwithsupplierinstead of the built-in instantiators.create(Class<?> clazz, ConstructorParameters constructorParameters) Indicates, that class should be constructed using given constructor parameters.create(String qualifiedClassName, Object[] constructorParameters, Class<?>[] constructorParameterTypes) Indicates, that class should be constructed using given constructor parameters.create(String qualifiedClassName, ConstructorParameters constructorParameters) Indicates, that class should be constructed using given constructor parameters.protected voidlogTestersAndClasses(org.slf4j.Logger logger, ClassAndFieldPredicatePair... classAndFieldPredicatePairs) quickly()Specifies generation of O(N) test objects for N fields.protected abstract voidSpecifies what test will be performed.Specifies what tests will be performed.Specifies generation of O(2^N) test objects for N fields.using(AbstractFieldValueChanger abstractFieldValueChanger) Specifies what field values changer will be used for testing.Also accepts a getter or setter whose name is the field name.withFieldPrefix(String prefix) Strips a prefix from field names before matching getters and setters.
-
Constructor Details
-
AbstractAssertion
public AbstractAssertion()
-
-
Method Details
-
using
Specifies what field values changer will be used for testing.- Parameters:
abstractFieldValueChanger- field values changer- Returns:
- itself
- See Also:
-
thoroughly
Specifies generation of O(2^N) test objects for N fields. A class with more thanThoroughFieldPermutator.MAX_FIELDSfields, including a nested one, uses the linear strategy instead. A warning names that class.- Returns:
- itself
-
quickly
Specifies generation of O(N) test objects for N fields.- Returns:
- itself
-
changingFinalFields
Also assigns new values tofinalfields when proving thatequals,hashCodeandtoStringsee 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
Strips a prefix from field names before matching getters and setters.withFieldPrefix("m")mapsmNametogetName.withFieldPrefix("m_")mapsm_nametogetName. A field that does not start with the prefix is matched as written.- Parameters:
prefix- prefix used on fields, never blank- Returns:
- itself
-
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
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 ofhashCode.- Returns:
- itself
-
testing
Specifies what tests will be performed.- Parameters:
methods- methods to test- Returns:
- itself
- See Also:
-
testing
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 instantiateconstructorParameters- constructor parametersconstructorParameterTypes- 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 instantiateconstructorParameters- 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 instantiateconstructorParameters- constructor parametersconstructorParameterTypes- constructor parameter's types- Returns:
- itself
- See Also:
-
create
Indicates, that class should be constructed using given constructor parameters. Constructor will be selected based on constructor parameter's types.- Parameters:
clazz- class to instantiateconstructorParameters- constructor parameters- Returns:
- itself
- See Also:
-
create
Instantiatesclazzwithsupplierinstead 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 instantiatesupplier- creates instances ofclazz- Returns:
- itself
-
runAssertions
protected abstract void runAssertions() -
logTestersAndClasses
protected void logTestersAndClasses(org.slf4j.Logger logger, ClassAndFieldPredicatePair... classAndFieldPredicatePairs)
-