Package nl._42.beanie.tester
Class BeanTester
java.lang.Object
nl._42.beanie.tester.BeanTester
Verifies the getter and setter methods of beans. The retrieved
value should be semantically equal to the initially set value.
- Author:
- Jeroen van Schagen
-
Constructor Summary
ConstructorDescriptionBeanTester
(BeanBuilder beanBuilder) BeanTester
(BeanBuilder beanBuilder, ObjectEqualizer equalizer) -
Method Summary
Modifier and TypeMethodDescriptionExcludes a class from testing.Excludes a property from testing.Excludes a pattern from testing.exclude
(org.springframework.core.type.filter.TypeFilter filter) Add an exclusion filter.include
(org.springframework.core.type.filter.TypeFilter filter) Add an inclusion filter.Include all beans.Include all beans with a nullary constructor.inherit
(boolean inherit) If we should also test the parent properties.void
verifyBean
(Class<?> beanClass) Verify the getter and setters of the specified bean.int
verifyBeans
(Class<?> basePackageClass) Verify the getter and setters of each bean classes, declared in the same package, or child packages, as the specified class.int
verifyBeans
(String basePackage) Verify the getter and setters of each bean classes, declared in the specified package, or child packages.void
verifyProperty
(Class<?> beanClass, String propertyName) Verify the getter and setter of a property.
-
Constructor Details
-
BeanTester
public BeanTester() -
BeanTester
-
BeanTester
-
-
Method Details
-
verifyBeans
Verify the getter and setters of each bean classes, declared in the same package, or child packages, as the specified class.- Parameters:
basePackageClass
- the base package class- Returns:
- the number of verified beans
-
verifyBeans
Verify the getter and setters of each bean classes, declared in the specified package, or child packages.- Parameters:
basePackage
- the base package to search for beans- Returns:
- the number of verified beans
-
verifyBean
Verify the getter and setters of the specified bean.- Parameters:
beanClass
- the bean class- Throws:
InconsistentGetterAndSetterException
- whenever an inconsistency was found
-
verifyProperty
Verify the getter and setter of a property.- Parameters:
beanClass
- the bean classpropertyName
- the property name
-
include
Add an inclusion filter.- Parameters:
filter
- the filter- Returns:
- this instance for chaining
-
includeAllWithNullaryConstructor
Include all beans with a nullary constructor.- Returns:
- this instance for chaining
-
includeAll
Include all beans.- Returns:
- this instance for chaining
-
exclude
Add an exclusion filter.- Parameters:
filter
- the filter- Returns:
- this instance for chaining
-
exclude
Excludes a pattern from testing.- Parameters:
pattern
- the pattern- Returns:
- this instance for chaining
-
exclude
Excludes a class from testing.- Parameters:
beanClass
- the bean class- Returns:
- this instance for chaining
-
exclude
Excludes a property from testing.- Parameters:
declaringClass
- the declaring classpropertyName
- name of the property- Returns:
- this instance for chaining
-
inherit
If we should also test the parent properties.- Parameters:
inherit
- to inherit- Returns:
- this instance for chaining
-