Class JavaBeanTesterBuilder<T,E>
java.lang.Object
com.codebox.bean.JavaBeanTesterBuilder<T,E>
- Type Parameters:
T- the type under testE- the extension type used for equality-related checks
Fluent configuration object returned by
JavaBeanTester.builder(Class).
Configure optional checks by chaining methods such as checkEquals(), checkSerializable(),
loadData(), or skip(String...), then finish with a terminal method such as test(),
testInstance(Object), testEquals(Object, Object), testObjectMethods(), or
testPrivateConstructor().
-
Method Summary
Modifier and TypeMethodDescriptionEnablesclear()verification.checkClear(boolean value) Togglesclear()verification.Enables public-constructor verification.checkConstructor(boolean value) Toggles public-constructor verification.Enablesequals,hashCode,toString, andcanEqualverification.checkEquals(boolean value) Togglesequals,hashCode,toString, andcanEqualverification.Requires the type under test to be serializable and validates a serialization round-trip.checkSerializable(boolean value) Toggles strict serializable validation.loadData()Enables recursive sample-data generation for supported property types.loadData(boolean value) Toggles recursive sample-data generation for supported property types.Skips the supplied bean properties during getter/setter validation.Skip Strict Serializable is intended to relax strict check on serializable objects.voidtest()Runs the configured bean validation flow.voidtestEquals(T instance, T expected) Compares two prepared instances using the configured equality options.voidtestInstance(T instance) Runs getter/setter checks against the supplied instance.voidRuns only the object-method checks for the configured class.voidVerifies that a private constructor can be exercised.
-
Method Details
-
checkClear
-
checkClear
Togglesclear()verification.- Parameters:
value-trueto enable the check,falseto disable it- Returns:
- this builder
-
checkConstructor
Enables public-constructor verification.- Returns:
- this builder
-
checkConstructor
Toggles public-constructor verification.- Parameters:
value-trueto enable the check,falseto disable it- Returns:
- this builder
-
checkEquals
Enablesequals,hashCode,toString, andcanEqualverification.- Returns:
- this builder
-
checkEquals
Togglesequals,hashCode,toString, andcanEqualverification.- Parameters:
value-trueto enable the check,falseto disable it- Returns:
- this builder
-
checkSerializable
Requires the type under test to be serializable and validates a serialization round-trip.- Returns:
- this builder
-
checkSerializable
Toggles strict serializable validation.- Parameters:
value-trueto require serialization support,falseto skip the strict requirement- Returns:
- this builder
-
loadData
Enables recursive sample-data generation for supported property types.- Returns:
- this builder
-
loadData
Toggles recursive sample-data generation for supported property types.- Parameters:
value-trueto enable generated data,falseto disable it- Returns:
- this builder
-
skipStrictSerializable
Skip Strict Serializable is intended to relax strict check on serializable objects. For complex objects, strict checking will result in issues with equals check. Testing has shown this to be generally not a normal use case of javabean tester as it is normally used with POJOs only. In such a case, caller will get an error and if there is not actually a code problem they should turn this skip on.- Returns:
- the java bean tester builder
-
skip
Skips the supplied bean properties during getter/setter validation.- Parameters:
propertyNames- the bean property names to exclude- Returns:
- this builder
-
test
public void test()Runs the configured bean validation flow. -
testPrivateConstructor
public void testPrivateConstructor()Verifies that a private constructor can be exercised. -
testObjectMethods
public void testObjectMethods()Runs only the object-method checks for the configured class. -
testInstance
Runs getter/setter checks against the supplied instance.- Parameters:
instance- the instance to populate and verify
-
testEquals
-