T - The bean typepublic class BeanTestBase<T> extends TestValueFactory
| Modifier and Type | Class and Description |
|---|---|
protected static class |
BeanTestBase.ConstructorParameters
Constructor parameter descriptor.
|
| Modifier and Type | Field and Description |
|---|---|
protected static BeanTestBase.ConstructorParameters |
DEFAULT_CONSTRUCTOR_PARAMETERS
Default constructor parameters.
|
| Constructor and Description |
|---|
BeanTestBase() |
BeanTestBase(boolean treatIgnoreAsSuccess) |
BeanTestBase(Class<T> beanClass)
Create a new BeanTestBase instance.
|
BeanTestBase(Class<T> beanClass,
boolean treatIgnoreAsSuccess)
Create a new BeanTestBase instance.
|
BeanTestBase(Class<T> beanClass,
int testRuns)
Create a new BeanTestBase instance.
|
BeanTestBase(Class<T> beanClass,
int testRuns,
boolean treatIgnoreAsSuccess)
Create a new BeanTestBase instance.
|
BeanTestBase(int testRuns) |
BeanTestBase(int testRuns,
boolean treatIgnoreAsSuccess) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertEquals(String message,
Collection<?> expected,
Collection<?> actual) |
protected void |
assertEquals(String message,
Object expected,
Object actual)
Assert equals with support for Double/double and Float/float, arrays and collections.
|
void |
copyConstructorEmptyEqualsTest()
Test for copy constructor, if any, and equals.
|
protected void |
copyConstructorEmptyEqualsTestImpl() |
void |
copyConstructorEmptyValuesTest()
Test for copy constructor, if any.
|
protected void |
copyConstructorEmptyValuesTestImpl() |
void |
copyConstructorEqualsTest()
Test for copy constructor, if any, and equals.
|
protected void |
copyConstructorEqualsTestImpl() |
void |
copyConstructorValuesTest()
Test for copy constructor, if any.
|
protected void |
copyConstructorValuesTestImpl() |
protected T |
createInstance(BeanTestBase.ConstructorParameters constructorParameters)
Create a bean instance using this parameter constructor.
|
void |
equalsIdentityTest()
Test the equals method with identical instances.
|
protected void |
equalsIdentityTestImpl() |
void |
equalsValuesTest()
Test the equals method with equal values.
|
protected void |
equalsValuesTestImpl() |
protected Map<String,Object> |
fillBean(T bean,
String[] propertiesToOmit) |
protected Object |
fillProperty(T entity,
String propertyName)
Set a value for the given field using a setter if possible.
|
protected Collection<String> |
getBeanPropertyNames()
Get all bean property names.
|
protected BeanTestBase.ConstructorParameters[] |
getConstructorParameters()
Get all constructor parameter sets.
|
protected Object |
getFieldDefaultValue(String propertyName) |
protected Object |
getFieldValue(T entity,
String propertyName)
Get the value of the given field using a getter if possible.
|
protected String[] |
getIgnorePropertyNames()
Get the property names to ignore in this test.
|
void |
hashCodeTest()
Test the hashCode method.
|
protected void |
hashCodeTestImpl() |
protected boolean |
isBeanFieldCandidate(Field field)
Is the given field a bean field candidate?
|
void |
propertyTestForAllConstructors()
Property test for all constructors.
|
protected void |
propertyTestForAllConstructorsImpl() |
void |
toStringTestForAllConstructorsEmpty()
Calling toString() on an empty bean.
|
protected void |
toStringTestForAllConstructorsEmptyImpl() |
void |
toStringTestForAllConstructorsFilled()
Calling toString() on an filled bean.
|
protected void |
toStringTestForAllConstructorsFilledImpl() |
createValue, getNextTestValueprotected static final BeanTestBase.ConstructorParameters DEFAULT_CONSTRUCTOR_PARAMETERS
public BeanTestBase(Class<T> beanClass)
beanClass - The bean class to testpublic BeanTestBase(Class<T> beanClass, boolean treatIgnoreAsSuccess)
beanClass - The bean class to testpublic BeanTestBase(Class<T> beanClass, int testRuns)
beanClass - The bean class to testpublic BeanTestBase(Class<T> beanClass, int testRuns, boolean treatIgnoreAsSuccess)
beanClass - The bean class to testpublic BeanTestBase()
public BeanTestBase(int testRuns)
public BeanTestBase(boolean treatIgnoreAsSuccess)
public BeanTestBase(int testRuns,
boolean treatIgnoreAsSuccess)
protected Collection<String> getBeanPropertyNames()
isBeanFieldCandidate(Field)protected Object fillProperty(T entity, String propertyName) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException
protected Object getFieldValue(T entity, String propertyName) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException
protected String[] getIgnorePropertyNames()
protected boolean isBeanFieldCandidate(Field field)
field - The fieldtrue if the given field is a bean field candidateprotected T createInstance(BeanTestBase.ConstructorParameters constructorParameters) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
NoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionprotected BeanTestBase.ConstructorParameters[] getConstructorParameters()
protected void assertEquals(String message, Object expected, Object actual)
protected void assertEquals(String message, Collection<?> expected, Collection<?> actual)
protected Map<String,Object> fillBean(T bean, String[] propertiesToOmit) throws IllegalAccessException, InvocationTargetException, NoSuchFieldException
IllegalAccessExceptionInvocationTargetExceptionNoSuchFieldExceptionpublic void propertyTestForAllConstructors()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void propertyTestForAllConstructorsImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void copyConstructorEqualsTest()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void copyConstructorEqualsTestImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void copyConstructorValuesTest()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void copyConstructorValuesTestImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void copyConstructorEmptyEqualsTest()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void copyConstructorEmptyEqualsTestImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void copyConstructorEmptyValuesTest()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void copyConstructorEmptyValuesTestImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void toStringTestForAllConstructorsEmpty()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void toStringTestForAllConstructorsEmptyImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void toStringTestForAllConstructorsFilled()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
protected void toStringTestForAllConstructorsFilledImpl()
throws NoSuchMethodException,
InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException
public void equalsIdentityTest()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
protected void equalsIdentityTestImpl()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
public void equalsValuesTest()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
protected void equalsValuesTestImpl()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
public void hashCodeTest()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
protected void hashCodeTestImpl()
throws InstantiationException,
IllegalAccessException,
InvocationTargetException,
NoSuchFieldException,
NoSuchMethodException
Copyright © 2013–2020 mklinger GmbH. All rights reserved.