Interface DelegateTests<T>

  • Type Parameters:
    T - The type of object to test.

    public interface DelegateTests<T>
    Base interface for testing that methods delegate to another object of the same type.
    Author:
    Rob Spoor
    • Method Detail

      • delegateType

        Class<T> delegateType()
        Returns the type to delegate to.
        Returns:
        The type to delegate to.
      • wrap

        T wrap​(T delegate)
        Creates the object to test.
        Parameters:
        delegate - The delegate to test against.
        Returns:
        The created object.
      • method

        default DelegateTests.DelegateMethod<T> method​(String name)
        Returns a delegate method for a method without arguments.
        Parameters:
        name - The name for the method.
        Returns:
        A delegate method for the method with the given name and no arguments.
      • method

        default DelegateTests.DelegateMethod<T> method​(String name,
                                                       Class<?>... parameterTypes)
        Returns a delegate method for a method.

        The method will be invoked with default arguments; 0 for int, false for boolean, null for objects, etc. This may cause an error if the result of the method is invoked on an object that performs some input validation before delegating. Use method(String, Parameter...) instead if the default arguments are not sufficient.

        Parameters:
        name - The name for the method.
        parameterTypes - The parameter types for the method.
        Returns:
        A delegate method for the method with the given name and parameter types.
      • method

        default DelegateTests.DelegateMethod<T> method​(String name,
                                                       DelegateTests.Parameter... parameters)
        Returns a delegate method for a method.
        Parameters:
        name - The name for the method.
        parameters - The parameters for the method.
        Returns:
        A delegate method for the method with the given name and parameters.
      • parameter

        default <U> DelegateTests.Parameter parameter​(U value)
        Creates a new method parameter. This is shorthand for parameter(value.getClass(), value).
        Type Parameters:
        U - The parameter type.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(Class<?> type)
        Creates a new method parameter. This is shorthand for parameter(type, defaultValue) where defaultValue is the default value for the given type: 0 for int, false for boolean, null for objects, etc.
        Parameters:
        type - The parameter type.
        Returns:
        The created method parameter.
      • parameter

        default <U> DelegateTests.Parameter parameter​(Class<U> type,
                                                      U value)
        Creates a new method parameter.
        Type Parameters:
        U - The parameter type.
        Parameters:
        type - The parameter type.
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(boolean value)
        Creates a new boolean method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(char value)
        Creates a new char method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(byte value)
        Creates a new byte method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(short value)
        Creates a new short method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(int value)
        Creates a new int method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(long value)
        Creates a new long method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(float value)
        Creates a new float method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.
      • parameter

        default DelegateTests.Parameter parameter​(double value)
        Creates a new double method parameter.
        Parameters:
        value - The value for the parameter.
        Returns:
        The created method parameter.