Class AbstractTestModule

java.lang.Object
com.google.inject.AbstractModule
com.peterphi.std.guice.testing.AbstractTestModule
All Implemented Interfaces:
com.google.inject.Module

public abstract class AbstractTestModule extends com.google.inject.AbstractModule
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> void
    bindMock(com.google.inject.Key<T> key, Class<T> clazz, String mockName)
    Create a custom binding for the provided class as a mockito mock
    protected <T> void
    bindNamedMock(String name, Class<T> clazz)
    Create a named binding for the provided class as a mockito mock
    protected <T> void
    mock(Class<T> clazz)
    Create a binding for the provided class as a mockito mock

    Methods inherited from class com.google.inject.AbstractModule

    addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding

    Methods inherited from class java.lang.Object

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

    • AbstractTestModule

      public AbstractTestModule()
  • Method Details

    • mock

      protected <T> void mock(Class<T> clazz)
      Create a binding for the provided class as a mockito mock
      Type Parameters:
      T -
      Parameters:
      clazz -
    • bindNamedMock

      protected <T> void bindNamedMock(String name, Class<T> clazz)
      Create a named binding for the provided class as a mockito mock
      Type Parameters:
      T -
      Parameters:
      name - shorthand for specifying a Named binding
      clazz -
    • bindMock

      protected <T> void bindMock(com.google.inject.Key<T> key, Class<T> clazz, String mockName)
      Create a custom binding for the provided class as a mockito mock
      Type Parameters:
      T -
      Parameters:
      key - the key to use for the binding
      clazz - the class to mock
      mockName - the name for the mockito mock (note: not the name of the Guice binding. If none is specified then a default name will be created based on the key