use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_addOrderedTypes.
@Test
public void testListInjection_addOrderedTypes() {
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").insertBefore("5value", MockInterface5.class).add("2value").addAfter("6value", MockInterface5.class).add("3value").add(MockInterface5.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";1value;2value;5value;xyz;6value;3value", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testListInjection_addValue.
@Test
public void testListInjection_addValue() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_ListConfiguration.class);
binder.bindList(Object.class, "xyz").add("xvalue").add("yvalue");
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";xvalue;yvalue", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testMapInjection_Empty.
@Test
public void testMapInjection_Empty() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_MapConfiguration.class);
// empty map must be still bound
binder.bindMap(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 testConstructorInjection_Named.
@Test
public void testConstructorInjection_Named() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1.class);
binder.bind(Key.get(MockInterface1.class, "one")).to(MockImplementation1Alt.class);
binder.bind(Key.get(MockInterface1.class, "two")).to(MockImplementation1Alt2.class);
binder.bind(MockInterface4.class).to(MockImplementation4Alt.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface4 service = injector.getInstance(MockInterface4.class);
assertNotNull(service);
assertEquals("constructor_alt2", service.getName());
}
use of org.apache.cayenne.di.mock.MockInterface1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testMapInjection.
@Test
public void testMapInjection() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1_MapConfiguration.class);
binder.bindMap(Object.class, "xyz").put("x", "xvalue").put("y", "yvalue").put("x", "xvalue1");
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals(";x=xvalue1;y=yvalue", service.getName());
}
Aggregations