Class EventContext
java.lang.Object
ru.vyarus.dropwizard.guice.test.jupiter.env.listen.EventContext
Event context wraps junit
ExtensionContext and 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
ConstructorsConstructorDescriptionEventContext(org.junit.jupiter.api.extension.ExtensionContext context, boolean debug) Create event context. -
Method Summary
Modifier and TypeMethodDescription<T> TShortcut to get bean directly from injector.Note that client is created even for pure guicey tests (in case if something external must be called).com.google.inject.InjectorNormally, it is impossible that injector would not be found (under called lifecycle methods).org.junit.jupiter.api.extension.ExtensionContextio.dropwizard.testing.DropwizardTestSupport<?>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).boolean
-
Constructor Details
-
EventContext
public EventContext(org.junit.jupiter.api.extension.ExtensionContext context, boolean debug) Create event context.- Parameters:
context- extension contextdebug- true if debug enabled in extension
-
-
Method Details
-
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:
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:
IllegalStateException- if the injector object not found (should be impossible)
-
getBean
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
Note that client is created even for pure guicey tests (in case if something external must be called).- Returns:
- client instance
- Throws:
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
-