Package dev.orne.beans.converters
Class AbstractConverterTest
java.lang.Object
dev.orne.beans.converters.AbstractConverterTest
Abstract class for converters unit tests.
- Since:
- 0.1
- Version:
- 1.0, 2020-05
- Author:
- (w) Iker Hernaez
- See Also:
-
AbstractConverter
-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.apache.commons.beanutils.converters.AbstractConverter
The converter to test.protected final Class<?>
The conversion default target type. -
Constructor Summary
ConstructorDescriptionAbstractConverterTest
(@NotNull Class<?> targetType, @NotNull org.apache.commons.beanutils.converters.AbstractConverter converter) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertFail
(@NotNull org.apache.commons.beanutils.Converter converter, @NotNull Class<?> type, Object value) Asserts that the conversion of the specified value to the specified type fails.protected void
assertFail
(Object value) Asserts that the conversion of the specified value fails both to the default target type, the tested converter default type and an unsupported type (Exception
).protected void
assertSuccess
(@NotNull org.apache.commons.beanutils.Converter converter, @NotNull Class<?> type, Object value, Object expectedResult) Asserts that the conversion of the specified value to the specified type result in the specified result.protected void
assertSuccess
(@NotNull org.apache.commons.beanutils.Converter converter, Object value, Object expectedResult, Object defaultValue) Asserts that the conversion of the specified value results in the specified expected result both for the default target type and the tested converter default type.protected void
assertSuccess
(Object value, Object expectedResult) Asserts that the conversion of the specified value results in the specified expected result both for the default target type and the tested converter default type.protected void
assertSuccessTyped
(Object value, Object expectedResult) Asserts that the conversion to the default target type results in the specified expected result.
-
Field Details
-
converter
protected final org.apache.commons.beanutils.converters.AbstractConverter converterThe converter to test. -
targetType
The conversion default target type.
-
-
Constructor Details
-
AbstractConverterTest
public AbstractConverterTest(@NotNull @NotNull Class<?> targetType, @NotNull @NotNull org.apache.commons.beanutils.converters.AbstractConverter converter) Creates a new instance.- Parameters:
targetType
- The conversion default target type.converter
- The converter to test.
-
-
Method Details
-
assertFail
Asserts that the conversion of the specified value fails both to the default target type, the tested converter default type and an unsupported type (Exception
).- Parameters:
value
- The value to convert.
-
assertFail
protected void assertFail(@NotNull @NotNull org.apache.commons.beanutils.Converter converter, @NotNull @NotNull Class<?> type, Object value) Asserts that the conversion of the specified value to the specified type fails.- Parameters:
converter
- The converter to test.type
- The conversion target type.value
- The value to convert.
-
assertSuccess
Asserts that the conversion of the specified value results in the specified expected result both for the default target type and the tested converter default type. Also asserts that the conversion of the specified value to an unsupported type (Exception
) fails.- Parameters:
value
- The value to convert.expectedResult
- The expected result.
-
assertSuccessTyped
Asserts that the conversion to the default target type results in the specified expected result. Also asserts that the conversion of the specified value to both the tested converter default type and an unsupported type (Exception
) fails.- Parameters:
value
- The value to convert.expectedResult
- The expected result.
-
assertSuccess
protected void assertSuccess(@NotNull @NotNull org.apache.commons.beanutils.Converter converter, Object value, Object expectedResult, Object defaultValue) Asserts that the conversion of the specified value results in the specified expected result both for the default target type and the tested converter default type. Also asserts that the conversion of the specified value to an unsupported type (Exception
) results in the specified default value.- Parameters:
converter
- The converter to test.value
- The value to convert.expectedResult
- The expected result.defaultValue
- The expected result when target type is not supported.
-
assertSuccess
protected void assertSuccess(@NotNull @NotNull org.apache.commons.beanutils.Converter converter, @NotNull @NotNull Class<?> type, Object value, Object expectedResult) Asserts that the conversion of the specified value to the specified type result in the specified result.- Parameters:
converter
- The converter to test.type
- The conversion target type.value
- The value to convert.expectedResult
- The expected result.
-