Package io.trino.tempto.internal.context
Class GuiceTestContext
java.lang.Object
io.trino.tempto.internal.context.GuiceTestContext
- All Implemented Interfaces:
TestContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisTestContextand all childrenTestContexts.createChildContext(Iterable<State> newStatesIterable) Creates a new childTestContextwith newInjectorthat contains new states.createChildContext(Iterable<State> newStatesIterable, Iterable<com.google.inject.Module> overrideModules) <T> TgetDependency(Class<T> dependencyClass) Allows obtaining runtime dependency from within test body.<T> TgetDependency(Class<T> dependencyClass, String dependencyName) <T> Optional<T>getOptionalDependency(com.google.inject.Key key) <T> Optional<T>getOptionalDependency(Class<T> dependencyClass) Same asTestContext.getDependency(Class)but will return Optional.empty() if no binding is present for given class.<T> Optional<T>getOptionalDependency(Class<T> dependencyClass, String dependencyName) Same asTestContext.getDependency(Class, String)but will return Optional.empty() if no binding is present for given class.voidinjectMembers(Object instance) voidRegisters a callback that will be executed onTestContextclose.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.trino.tempto.context.TestContext
createChildContext
-
Constructor Details
-
GuiceTestContext
public GuiceTestContext(com.google.inject.Module... baseModules)
-
-
Method Details
-
getDependency
Description copied from interface:TestContextAllows 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:
getDependencyin interfaceTestContext- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtained- Returns:
- Dependency
-
getDependency
- Specified by:
getDependencyin interfaceTestContext
-
getOptionalDependency
Description copied from interface:TestContextSame asTestContext.getDependency(Class)but will return Optional.empty() if no binding is present for given class.- Specified by:
getOptionalDependencyin interfaceTestContext- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtained- Returns:
- Dependency
-
getOptionalDependency
Description copied from interface:TestContextSame asTestContext.getDependency(Class, String)but will return Optional.empty() if no binding is present for given class.- Specified by:
getOptionalDependencyin interfaceTestContext- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtaineddependencyName- Name of dependency- Returns:
- Dependency
-
getOptionalDependency
-
createChildContext
Description copied from interface:TestContextCreates a new childTestContextwith newInjectorthat contains new states.- Specified by:
createChildContextin interfaceTestContext- Parameters:
newStatesIterable- requested states- Returns:
- TestContext
-
createChildContext
public GuiceTestContext createChildContext(Iterable<State> newStatesIterable, Iterable<com.google.inject.Module> overrideModules) -
registerCloseCallback
Description copied from interface:TestContextRegisters a callback that will be executed onTestContextclose.- Specified by:
registerCloseCallbackin interfaceTestContext- Parameters:
callback- callback that will be executed onTestContextclose.
-
close
public void close()Description copied from interface:TestContextCloses thisTestContextand all childrenTestContexts.- Specified by:
closein interfaceTestContext
-
injectMembers
- Specified by:
injectMembersin interfaceTestContext
-