Search in sources :

Example 1 with Presets

use of se.jbee.inject.config.Presets in project silk by jbee.

the class TestExample1Binds method constructorArgumentsCanBePassedToBootstrappingUsingPresets.

@Test
public void constructorArgumentsCanBePassedToBootstrappingUsingPresets() {
    Properties props = new Properties();
    props.put("x", "abc");
    props.put("y", 12);
    Presets presets = Presets.EMPTY.preset(Properties.class, props);
    Globals globals = Globals.STANDARD.presets(presets);
    Injector injector = Bootstrap.injector(Example1Module1.class, globals);
    MyClass obj = injector.resolve(Dependency.dependency(MyClass.class));
    assertEquals(12, obj.twelve);
    assertEquals("abc", obj.abc);
}
Also used : Globals(se.jbee.inject.config.Globals) Presets(se.jbee.inject.config.Presets) Injector(se.jbee.inject.Injector) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with Presets

use of se.jbee.inject.config.Presets in project silk by jbee.

the class TestPresetModuleBinds method injector.

private static Injector injector() {
    Presets presets = Presets.EMPTY.preset(Properties.class, exampleProperties());
    presets = presets.preset(Typecast.listTypeOf(String.class), Arrays.asList("a", "b"));
    presets = presets.preset(Typecast.listTypeOf(Integer.class), Arrays.asList(1, 2));
    return Bootstrap.injector(PresetModuleBindsBundle.class, Globals.STANDARD.presets(presets));
}
Also used : Presets(se.jbee.inject.config.Presets)

Aggregations

Presets (se.jbee.inject.config.Presets)2 Properties (java.util.Properties)1 Test (org.junit.Test)1 Injector (se.jbee.inject.Injector)1 Globals (se.jbee.inject.config.Globals)1