Interface MockRegistry


public interface MockRegistry
This trait is meant to allow for unit testing when a service has cross-component or cross-service calls. The set of mocks or stubs will be matched by its class type upon a call of an external component or service.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final MockRegistry
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an empty instance of MockRegistry that can be chained with `withMock`
    withMock(Class<T> clazz, T instance)
    Returns a new MockRegistry with the new mock added to previous ones.
  • Field Details

  • Method Details

    • withMock

      <T> MockRegistry withMock(Class<T> clazz, T instance)
      Returns a new MockRegistry with the new mock added to previous ones.
      Type Parameters:
      T - The service interface to be mocked.
      Parameters:
      clazz - The class type used to identify the mock.
      instance - The instance object to be used as a mock-
      Returns:
      A copy of this MockRegistry.
    • create

      static MockRegistry create()
      Returns an empty instance of MockRegistry that can be chained with `withMock`
      Returns:
      a new instance of MockRegistry