Search in sources :

Example 1 with MockInterface1_Decorator1

use of org.apache.cayenne.di.mock.MockInterface1_Decorator1 in project cayenne by apache.

the class DefaultInjectorDecorationTest method testSingleDecorator_After.

@Test
public void testSingleDecorator_After() {
    Module module = binder -> {
        binder.bind(MockInterface1.class).to(MockImplementation1.class);
        binder.decorate(MockInterface1.class).after(MockInterface1_Decorator1.class);
    };
    DefaultInjector injector = new DefaultInjector(module);
    MockInterface1 service = injector.getInstance(MockInterface1.class);
    assertNotNull(service);
    assertEquals("[MyName]", service.getName());
}
Also used : MockInterface1(org.apache.cayenne.di.mock.MockInterface1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Assert.assertNotNull(org.junit.Assert.assertNotNull) MockInterface1_Decorator3(org.apache.cayenne.di.mock.MockInterface1_Decorator3) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator2(org.apache.cayenne.di.mock.MockInterface1_Decorator2) MockInterface1_Decorator5(org.apache.cayenne.di.mock.MockInterface1_Decorator5) Test(org.junit.Test) MockInterface1_Decorator4(org.apache.cayenne.di.mock.MockInterface1_Decorator4) Assert.assertEquals(org.junit.Assert.assertEquals) MockInterface1(org.apache.cayenne.di.mock.MockInterface1) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Test(org.junit.Test)

Example 2 with MockInterface1_Decorator1

use of org.apache.cayenne.di.mock.MockInterface1_Decorator1 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());
}
Also used : MockInterface1(org.apache.cayenne.di.mock.MockInterface1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Assert.assertNotNull(org.junit.Assert.assertNotNull) MockInterface1_Decorator3(org.apache.cayenne.di.mock.MockInterface1_Decorator3) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator2(org.apache.cayenne.di.mock.MockInterface1_Decorator2) MockInterface1_Decorator5(org.apache.cayenne.di.mock.MockInterface1_Decorator5) Test(org.junit.Test) MockInterface1_Decorator4(org.apache.cayenne.di.mock.MockInterface1_Decorator4) Assert.assertEquals(org.junit.Assert.assertEquals) MockInterface1(org.apache.cayenne.di.mock.MockInterface1) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Test(org.junit.Test)

Example 3 with MockInterface1_Decorator1

use of org.apache.cayenne.di.mock.MockInterface1_Decorator1 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());
}
Also used : MockInterface1(org.apache.cayenne.di.mock.MockInterface1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Assert.assertNotNull(org.junit.Assert.assertNotNull) MockInterface1_Decorator3(org.apache.cayenne.di.mock.MockInterface1_Decorator3) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator2(org.apache.cayenne.di.mock.MockInterface1_Decorator2) MockInterface1_Decorator5(org.apache.cayenne.di.mock.MockInterface1_Decorator5) Test(org.junit.Test) MockInterface1_Decorator4(org.apache.cayenne.di.mock.MockInterface1_Decorator4) Assert.assertEquals(org.junit.Assert.assertEquals) MockInterface1_Decorator3(org.apache.cayenne.di.mock.MockInterface1_Decorator3) MockInterface1_Decorator2(org.apache.cayenne.di.mock.MockInterface1_Decorator2) MockInterface1(org.apache.cayenne.di.mock.MockInterface1) Module(org.apache.cayenne.di.Module) MockImplementation1(org.apache.cayenne.di.mock.MockImplementation1) MockInterface1_Decorator1(org.apache.cayenne.di.mock.MockInterface1_Decorator1) Test(org.junit.Test)

Aggregations

Module (org.apache.cayenne.di.Module)3 MockImplementation1 (org.apache.cayenne.di.mock.MockImplementation1)3 MockInterface1 (org.apache.cayenne.di.mock.MockInterface1)3 MockInterface1_Decorator1 (org.apache.cayenne.di.mock.MockInterface1_Decorator1)3 MockInterface1_Decorator2 (org.apache.cayenne.di.mock.MockInterface1_Decorator2)3 MockInterface1_Decorator3 (org.apache.cayenne.di.mock.MockInterface1_Decorator3)3 MockInterface1_Decorator4 (org.apache.cayenne.di.mock.MockInterface1_Decorator4)3 MockInterface1_Decorator5 (org.apache.cayenne.di.mock.MockInterface1_Decorator5)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertNotNull (org.junit.Assert.assertNotNull)3 Test (org.junit.Test)3