Say I have a module:
Module extends AbstractModule { @Override protected void configure() { bind(String.class). annotatedWith(Names.named("annotation")). toInstance("DELIRIOUS"); } }
and I want to test the module and check if it adds the correct value to the String field, annotated with Names.named("annotation") without having a class and field, but getting the value directly from the injector:
@Test public void test() { Injector injector = Guice.createInjector(new Module());
java dependency-injection annotations guice configuration
Boris Pavlović Feb 25 2018-11-11T00: 00Z
source share