use of se.jbee.inject.Injector in project silk by jbee.
the class TestMultibindBinds method thatMultipleNamedElementsCanBeBound.
@Test
public void thatMultipleNamedElementsCanBeBound() {
Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
Integer[] foos = injector.resolve(dependency(Integer[].class).named(foo));
assertEqualSets(new Integer[] { 2, 3 }, foos);
Integer[] bars = injector.resolve(dependency(Integer[].class).named(bar));
assertEqualSets(new Integer[] { 4, 5 }, bars);
Integer[] defaults = injector.resolve(dependency(Integer[].class).named(Name.DEFAULT));
assertEqualSets(new Integer[] { 1, 11 }, defaults);
Integer[] anys = injector.resolve(dependency(Integer[].class).named(Name.ANY));
assertEqualSets(new Integer[] { 1, 2, 3, 4, 5, 11 }, anys);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMultibindBinds method thatMultipleBoundNamedElementsCanUsedAsList.
@Test
public void thatMultipleBoundNamedElementsCanUsedAsList() {
Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
List<Integer> foos = injector.resolve(dependency(listTypeOf(Integer.class)).named(foo));
assertEqualSets(new Integer[] { 2, 3 }, foos.toArray());
List<Integer> bars = injector.resolve(dependency(listTypeOf(Integer.class)).named(bar));
assertEqualSets(new Integer[] { 4, 5 }, bars.toArray());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestMultibindBinds method thatMultipleBoundNamedElementsCanUsedAsSet.
@Test
public void thatMultipleBoundNamedElementsCanUsedAsSet() {
Injector injector = Bootstrap.injector(MultibindBindsBundle.class);
Set<Integer> foos = injector.resolve(dependency(setTypeOf(Integer.class)).named(foo));
assertEqualSets(new Integer[] { 2, 3 }, foos.toArray());
Set<Integer> bars = injector.resolve(dependency(setTypeOf(Integer.class)).named(bar));
assertEqualSets(new Integer[] { 4, 5 }, bars.toArray());
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestRequiredProvidedBinds method thatAnExplicitBindReplacesTheProvidedImplementation.
@Test
public void thatAnExplicitBindReplacesTheProvidedImplementation() {
Injector injector = Bootstrap.injector(ExplicitBindBundle.class);
ExampleService s = injector.resolve(dependency(ExampleService.class));
assertTrue(s instanceof ExplicitExampleService);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestRequiredProvidedBinds method thatRequirementIsFulfilledByProvidedBind.
@Test
public void thatRequirementIsFulfilledByProvidedBind() {
Injector injector = Bootstrap.injector(RequiredProvidedBindsBundle.class);
assertNotNull(injector.resolve(dependency(ExampleService.class)));
}
Aggregations