use of org.apache.cayenne.di.mock.MockInterface5 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_OverrideExplicitlyBoundType.
@Test
public void testListInjection_OverrideExplicitlyBoundType() {
Module m1 = binder -> {
binder.bind(MockInterface5.class).to(MockImplementation5.class);
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz").add(MockInterface5.class);
};
Module m2 = binder -> binder.bind(MockInterface5.class).toInstance(new MockInterface5() {
@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());
}
use of org.apache.cayenne.di.mock.MockInterface5 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testMapInjection_OverrideExplicitlyBoundType.
@Test
public void testMapInjection_OverrideExplicitlyBoundType() {
Module m1 = binder -> {
binder.bind(MockInterface5.class).to(MockImplementation5.class);
binder.bind(MockInterface1.class).to(MockImplementation1_MapConfiguration.class);
binder.bindMap(Object.class, "xyz").put("a", MockInterface5.class);
};
Module m2 = binder -> binder.bind(MockInterface5.class).toInstance(new MockInterface5() {
@Override
public String toString() {
return "abc";
}
});
MockInterface1 service = new DefaultInjector(m1, m2).getInstance(MockInterface1.class);
assertEquals("Map element was not overridden in submodule", ";a=abc", service.getName());
}
Aggregations