Package io.trino.tempto.context
Interface TestContext
- All Known Implementing Classes:
GuiceTestContext
public interface TestContext
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisTestContextand all childrenTestContexts.default TestContextcreateChildContext(State... states) createChildContext(Iterable<State> states) Creates a new childTestContextwith newInjectorthat contains new states.<T> TgetDependency(Class<T> dependencyClass) Allows obtaining runtime dependency from within test body.<T> TgetDependency(Class<T> dependencyClass, String dependencyName) <T> Optional<T>getOptionalDependency(Class<T> dependencyClass) Same asgetDependency(Class)but will return Optional.empty() if no binding is present for given class.<T> Optional<T>getOptionalDependency(Class<T> dependencyClass, String dependencyName) Same asgetDependency(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.
-
Method Details
-
getDependency
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)- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtained- Returns:
- Dependency
-
getDependency
-
getOptionalDependency
Same asgetDependency(Class)but will return Optional.empty() if no binding is present for given class.- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtained- Returns:
- Dependency
-
getOptionalDependency
Same asgetDependency(Class, String)but will return Optional.empty() if no binding is present for given class.- Type Parameters:
T- template- Parameters:
dependencyClass- Class of dependency to be obtaineddependencyName- Name of dependency- Returns:
- Dependency
-
createChildContext
Creates a new childTestContextwith newInjectorthat contains new states.- Parameters:
states- requested states- Returns:
- TestContext
-
createChildContext
-
registerCloseCallback
Registers a callback that will be executed onTestContextclose.- Parameters:
callback- callback that will be executed onTestContextclose.
-
injectMembers
-
close
void close()Closes thisTestContextand all childrenTestContexts.
-