use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_addType.
@Test
public void testListInjection_addType() {
Module module = binder -> {
binder.bind(MockInterface5.class).to(MockImplementation5.class);
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz").add(MockInterface5.class).add("yvalue");
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";xyz;yvalue", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_empty.
@Test
public void testListInjection_empty() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz");
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals("", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_resumed.
@Test
public void testListInjection_resumed() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz").add("xvalue").add("yvalue");
binder.bindList(Object.class, "xyz").add("avalue");
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";xvalue;yvalue;avalue", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_addOrderedValues.
@Test
public void testListInjection_addOrderedValues() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bind(MockInterface5.class).to(MockImplementation5.class);
binder.bindList(Object.class, "xyz").add("1value").add("2value").addAfter("5value", MockInterface5.class).insertBefore("3value", MockInterface5.class).add(MockInterface5.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";1value;2value;3value;xyz;5value", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_OverrideImplicitlyBoundType.
@Test
public void testListInjection_OverrideImplicitlyBoundType() {
Module m1 = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz").add(MockImplementation5.class);
};
Module m2 = binder -> binder.bind(MockImplementation5.class).toInstance(new MockImplementation5() {
@Override
public String toString() {
return "abc";
}
});
MockInterface1 service = new DefaultInjector(m1, m2).getInstance(MockInterface1.class);
assertEquals("List element was not overridden in submodule", ";abc", service.getName());
}
Aggregations