use of org.apache.cayenne.di.mock.MockImplementation1 in project cayenne by apache.
the class DefaultInjectorBindingTest method testInstanceBinding.
@Test
public void testInstanceBinding() {
final MockImplementation1 instance = new MockImplementation1();
Module module = binder -> binder.bind(MockInterface1.class).toInstance(instance);
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertSame(instance, service);
}
use of org.apache.cayenne.di.mock.MockImplementation1 in project cayenne by apache.
the class DefaultInjectorDecorationTest method testDecoratorChain.
@Test
public void testDecoratorChain() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1.class);
binder.decorate(MockInterface1.class).before(MockInterface1_Decorator1.class);
binder.decorate(MockInterface1.class).before(MockInterface1_Decorator2.class);
binder.decorate(MockInterface1.class).after(MockInterface1_Decorator3.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals("<[{MyName}]>", service.getName());
}
use of org.apache.cayenne.di.mock.MockImplementation1 in project cayenne by apache.
the class DefaultInjectorDecorationTest method testSingleDecorator_Before.
@Test
public void testSingleDecorator_Before() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1.class);
binder.decorate(MockInterface1.class).before(MockInterface1_Decorator1.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface1 service = injector.getInstance(MockInterface1.class);
assertNotNull(service);
assertEquals("[MyName]", service.getName());
}
use of org.apache.cayenne.di.mock.MockImplementation1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testFieldInjectionSuperclass.
@Test
public void testFieldInjectionSuperclass() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1.class);
binder.bind(MockInterface2.class).to(MockImplementation2Sub1.class);
binder.bind(MockInterface3.class).to(MockImplementation3.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface2 service = injector.getInstance(MockInterface2.class);
assertNotNull(service);
assertEquals("altered_MyName:XName", service.getAlteredName());
}
use of org.apache.cayenne.di.mock.MockImplementation1 in project cayenne by apache.
the class DefaultInjectorInjectionTest method testConstructorInjection.
@Test
public void testConstructorInjection() {
Module module = binder -> {
binder.bind(MockInterface1.class).to(MockImplementation1.class);
binder.bind(MockInterface4.class).to(MockImplementation4.class);
};
DefaultInjector injector = new DefaultInjector(module);
MockInterface4 service = injector.getInstance(MockInterface4.class);
assertNotNull(service);
assertEquals("constructor_MyName", service.getName());
}
Aggregations