use of se.jbee.inject.Injector in project silk by jbee.
the class TestMultipleOptionChoicesBinds method thatMultipleOptionChoicesArePossible.
@Test
public void thatMultipleOptionChoicesArePossible() {
Options options = Options.STANDARD.chosen(Choices.A, Choices.D);
Globals globals = Globals.STANDARD.options(options);
Injector injector = Bootstrap.injector(RootBundle.class, globals);
assertEqualSets(new String[] { "A", "D" }, injector.resolve(dependency(String[].class)));
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestOptionBinds method assertOptionResolvedToValue.
private static void assertOptionResolvedToValue(Machine actualOption, String expected) {
Options options = Options.STANDARD.chosen(actualOption);
Injector injector = Bootstrap.injector(ModularBindsBundle.class, Globals.STANDARD.options(options));
String[] actual = injector.resolve(dependency(String[].class));
assertArrayEquals(new String[] { expected }, actual);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestRequiredProvidedBinds method thatUnusedProvidedBindIsNotAddedToInjectorContext.
@Test
public void thatUnusedProvidedBindIsNotAddedToInjectorContext() {
Injector injector = Bootstrap.injector(RequiredProvidedBindsBundle.class);
try {
injector.resolve(dependency(UnusedImpl.class));
fail("Should not be bound and therefore throw below exception");
} catch (NoResourceForDependency e) {
// expected this
} catch (Throwable e) {
fail("Expected another exception but got: " + e);
}
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestStateDependentBinds method thatStateChangeIsResolvedToAnotherImplementation.
@Test
public void thatStateChangeIsResolvedToAnotherImplementation() {
Injector injector = Bootstrap.injector(StateDependentBindsModule1.class);
assertStateChangeIsResolvedToAnotherImplementation(injector);
}
use of se.jbee.inject.Injector in project silk by jbee.
the class TestStateDependentBinds method thatStateChangeIsProvidedToAnotherImplementation.
@Test
public void thatStateChangeIsProvidedToAnotherImplementation() {
Injector injector = Bootstrap.injector(StateDependentBindsBundle.class);
StatefulObject config = injector.resolve(dependency(StatefulObject.class));
Provider<Validator> v = injector.resolve(dependency(providerTypeOf(Validator.class)));
String input = "input";
assertTrue(v.provide().valid(input));
config.setValidationStrength(ValidationStrength.STRICT);
assertFalse(v.provide().valid(input));
config.setValidationStrength(ValidationStrength.PERMISSIVE);
assertTrue(v.provide().valid(input));
}
Aggregations