@Test public void testComponent() { Component component = underTest.createComponent(); assertThat(component, notNullValue()); assertThat(component, instanceOf(TestComponent.class)); verify(componentDecorator).decorate(any(Component.class)); TestComponent testComponent = (TestComponent) component; assertThat(testComponent.getWrappedObject(), instanceOf(DefaultComponent.class)); }
public Component createComponent() { Component component = new DefaultComponent(); for (ComponentDecorator componentDecorator : componentDecorators) { component = componentDecorator.decorate(component); } return component; }
ComponentFactory { public Component createComponent() { Component component = new DefaultComponent(); for (ComponentDecorator componentDecorator : componentDecorators) { component = componentDecorator.decorate(component); } return component; } }
ComponentFactory { public Component createComponent() { Component component = new DefaultComponent(); for (ComponentDecorator componentDecorator : componentDecorators) { component = componentDecorator.decorate(component); } return component; } @Inject  ComponentFactory(final Set<ComponentDecorator> componentDecorators); }
ComponentFactory { public Component createComponent() { Component component = new DefaultComponent(); for (ComponentDecorator componentDecorator : componentDecorators) { component = componentDecorator.decorate(component); } return component; } @Inject  ComponentFactory(final Set<ComponentDecorator> componentDecorators); Component createComponent(); }
ComponentFactory { public Component createComponent() { Component component = new DefaultComponent(); for (ComponentDecorator componentDecorator : componentDecorators) { component = componentDecorator.decorate(component); } return component; } @Inject  ComponentFactory(final Set<ComponentDecorator> componentDecorators); Component createComponent();  }