ComponentXOFactory { public ComponentXO createComponentXO() { ComponentXO componentXO = new DefaultComponentXO(); for (ComponentXODecorator componentXODecorator : componentXODecorators) { componentXO = componentXODecorator.decorate(componentXO); } return componentXO; } @Inject  ComponentXOFactory(final Set<ComponentXODecorator> componentXODecorators); ComponentXO createComponentXO();  }
@Test public void testComponentXO() { ComponentXO componentXO = underTest.createComponentXO(); assertThat(componentXO, notNullValue()); assertThat(componentXO, instanceOf(TestComponentXO.class)); verify(componentXODecorator).decorate(any(ComponentXO.class)); TestComponentXO testComponentXO = (TestComponentXO) componentXO; assertThat(testComponentXO.getWrappedObject(), instanceOf(DefaultComponentXO.class)); assertThat(testComponentXO.getDecoratedExtraJsonAttributes(), hasEntry("foo", "bar")); }