Class AbstractConverterTest

java.lang.Object
dev.orne.beans.converters.AbstractConverterTest

public abstract class AbstractConverterTest extends Object
Abstract class for converters unit tests.
Since:
0.1
Version:
1.0, 2020-05
Author:
(w) Iker Hernaez
See Also:
  • AbstractConverter
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.apache.commons.beanutils.converters.AbstractConverter
    The converter to test.
    protected final Class<?>
    The conversion default target type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractConverterTest(@NotNull Class<?> targetType, @NotNull org.apache.commons.beanutils.converters.AbstractConverter converter)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • converter

      protected final org.apache.commons.beanutils.converters.AbstractConverter converter
      The converter to test.
    • targetType

      protected final Class<?> 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

      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).
      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

      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. 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

      protected void assertSuccessTyped(Object value, Object expectedResult)
      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.