public class PropertiesTester extends AbstractTester<PropertiesTester>
| Modifier and Type | Field and Description |
|---|---|
protected List<String> |
excludesByName
Property names exclusion list.
|
protected List<Class<?>> |
excludesByType
Property types exclusion list.
|
protected Map<String,Collection<String>> |
nameMappings
Property names mappings.
|
mappings| Constructor and Description |
|---|
PropertiesTester() |
| Modifier and Type | Method and Description |
|---|---|
PropertiesTester |
setNameExclusions(String... names)
Sets a list of properties you want to exclude by name.
|
PropertiesTester |
setNameMappings(String[]... mappings)
Sets the properties mapping by specifying field to property associations allowing to test properties which uses a
field with a different name.
|
PropertiesTester |
setTypeExclusions(Class<?>... types)
Sets the list of property types that are not going to be tested.
|
PropertiesTester |
test(Class<?> type,
String fieldName,
Object value)
Tests a property by name checking the accessor methods work as expected.
|
PropertiesTester |
testAll(Class<?> type)
Tests all the properties defined in this class.
|
PropertiesTester |
testAll(Class<?> type,
boolean definedOnly)
Test all the properties in this class using the
definedOnly parameter to restrict the set to locally
defined properties or not. |
addMapping, addMapping, getInstanceprotected Map<String,Collection<String>> nameMappings
public PropertiesTester setNameExclusions(String... names)
setTypeExclusions instead.names - the list of property names you want to exclude.PropertiesTester instance.public PropertiesTester setTypeExclusions(Class<?>... types)
types - the list of types you want to be excluded from properties testing.PropertiesTester instance.public PropertiesTester setNameMappings(String[]... mappings)
{"name", "authority"} if you have something like:
private String name;
public void setAuthority(String name) {
this.name = name;
}
If the mapping uses a field defined in a superclass then you should prefix the field with the hash (#) symbol,
like {"#inheritedFieldName", "propertyName"}, if you have something like:
public void setPropertyName(String name) {
super.inherithedFieldName = name;
}
mappings - a list of string arrays where each array defines in it's first position the field name and in all
subsequent positions the properties using that field. Multiple properties can be specified for each
mapping and multiple mappings can be set.PropertiesTester instance.public PropertiesTester testAll(Class<?> type) throws Exception
type - the class the test is going to be run on.PropertiesTester instance.Exception - thrown if any of the tests fail.public PropertiesTester testAll(Class<?> type, boolean definedOnly) throws Exception
definedOnly parameter to restrict the set to locally
defined properties or not. A property is considered to have been defined locally if the class defines a field
member of the same type used in the accessor methods.type - the class the test is going to be run on.definedOnly - determines the set of properties to be tested: if you want to test accessor methods overriding
superclass accessor methods or accessor methods using inherited fields you need to set this value to
false.PropertiesTester instance.Exception - thrown if any of the tests fail.public PropertiesTester test(Class<?> type, String fieldName, Object value) throws Exception
type - the class on which the test is going to be run.fieldName - the name of the property to test.value - the value used to check the accessor methods.PropertiesTester instance.Exception - thrown if any of the tests fail.Copyright © 2015. All rights reserved.