Class EventContext
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.jupiter.env.listen.EventContext
-
public class EventContext extends java.lang.ObjectEvent context wraps junitExtensionContextand provides access for the main test objects (like injector, test support and http client). Custom object is required mainly for lambda even listeners, which are unable to see default interface methods.- Since:
- 20.02.2025
-
-
Constructor Summary
Constructors Constructor Description EventContext(org.junit.jupiter.api.extension.ExtensionContext context, boolean debug)Create event context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetBean(java.lang.Class<T> type)Shortcut to get bean directly from injector.ClientSupportgetClient()Note that client is created even for pure guicey tests (in case if something external must be called).com.google.inject.InjectorgetInjector()Normally, it is impossible that injector would not be found (under called lifecycle methods).org.junit.jupiter.api.extension.ExtensionContextgetJunitContext()io.dropwizard.testing.DropwizardTestSupport<?>getSupport()Normally, it is impossible that support would not be found (under called lifecycle methods).booleanisDebug()Useful to bind debug options on the extension debug (no need for additional keys).booleanisWebStarted()
-
-
-
Method Detail
-
getJunitContext
public org.junit.jupiter.api.extension.ExtensionContext getJunitContext()
- Returns:
- junit context
-
isDebug
public boolean isDebug()
Useful to bind debug options on the extension debug (no need for additional keys).- Returns:
- true if debug is enabled on guicey extension
-
getSupport
public io.dropwizard.testing.DropwizardTestSupport<?> getSupport()
Normally, it is impossible that support would not be found (under called lifecycle methods).- Returns:
- dropwizard support object (or guicey support)
- Throws:
java.lang.IllegalStateException- if the support object not found (should be impossible)
-
getInjector
public com.google.inject.Injector getInjector()
Normally, it is impossible that injector would not be found (under called lifecycle methods).- Returns:
- injector instance
- Throws:
java.lang.IllegalStateException- if the injector object not found (should be impossible)
-
getBean
public <T> T getBean(java.lang.Class<T> type)
Shortcut to get bean directly from injector.- Type Parameters:
T- bean type- Parameters:
type- bean class- Returns:
- bean instance, never null (throw error if not found)
-
getClient
public ClientSupport getClient()
Note that client is created even for pure guicey tests (in case if something external must be called).- Returns:
- client instance
- Throws:
java.lang.IllegalStateException- if the client object not found (should be impossible)
-
isWebStarted
public boolean isWebStarted()
- Returns:
- true if complete application started, false for guice-only part
-
-