Class GuiceTestContext

java.lang.Object
io.trino.tempto.internal.context.GuiceTestContext
All Implemented Interfaces:
TestContext

public class GuiceTestContext extends Object implements TestContext
  • Constructor Details

    • GuiceTestContext

      public GuiceTestContext(com.google.inject.Module... baseModules)
  • Method Details

    • getDependency

      public <T> T getDependency(Class<T> dependencyClass)
      Description copied from interface: TestContext
      Allows obtaining runtime dependency from within test body. Common types of dependencies would be State instance coming out of RequirementFulfillers and services for performing work on cluster (like QueryExecutor, HdfsClient, RemoteExecutor)
      Specified by:
      getDependency in interface TestContext
      Type Parameters:
      T - template
      Parameters:
      dependencyClass - Class of dependency to be obtained
      Returns:
      Dependency
    • getDependency

      public <T> T getDependency(Class<T> dependencyClass, String dependencyName)
      Specified by:
      getDependency in interface TestContext
    • getOptionalDependency

      public <T> Optional<T> getOptionalDependency(Class<T> dependencyClass)
      Description copied from interface: TestContext
      Same as TestContext.getDependency(Class) but will return Optional.empty() if no binding is present for given class.
      Specified by:
      getOptionalDependency in interface TestContext
      Type Parameters:
      T - template
      Parameters:
      dependencyClass - Class of dependency to be obtained
      Returns:
      Dependency
    • getOptionalDependency

      public <T> Optional<T> getOptionalDependency(Class<T> dependencyClass, String dependencyName)
      Description copied from interface: TestContext
      Same as TestContext.getDependency(Class, String) but will return Optional.empty() if no binding is present for given class.
      Specified by:
      getOptionalDependency in interface TestContext
      Type Parameters:
      T - template
      Parameters:
      dependencyClass - Class of dependency to be obtained
      dependencyName - Name of dependency
      Returns:
      Dependency
    • getOptionalDependency

      public <T> Optional<T> getOptionalDependency(com.google.inject.Key key)
    • createChildContext

      public GuiceTestContext createChildContext(Iterable<State> newStatesIterable)
      Description copied from interface: TestContext
      Creates a new child TestContext with new Injector that contains new states.
      Specified by:
      createChildContext in interface TestContext
      Parameters:
      newStatesIterable - requested states
      Returns:
      TestContext
    • createChildContext

      public GuiceTestContext createChildContext(Iterable<State> newStatesIterable, Iterable<com.google.inject.Module> overrideModules)
    • registerCloseCallback

      public void registerCloseCallback(TestContextCloseCallback callback)
      Description copied from interface: TestContext
      Registers a callback that will be executed on TestContext close.
      Specified by:
      registerCloseCallback in interface TestContext
      Parameters:
      callback - callback that will be executed on TestContext close.
    • close

      public void close()
      Description copied from interface: TestContext
      Closes this TestContext and all children TestContexts.
      Specified by:
      close in interface TestContext
    • injectMembers

      public void injectMembers(Object instance)
      Specified by:
      injectMembers in interface TestContext