### Question:
MyFacesDecorateAllHandlerDelegate implements DecorateAllHandler.Delegate { public DecoratedChild createdDecoratedChild(FaceletHandler handler, List<FaceletHandler> variableDeclarationHandlers) { return new MojarraDecoratedChild(handler, variableDeclarationHandlers); }  Type getType(FaceletHandler handler); DecoratedChild createdDecoratedChild(FaceletHandler handler, List<FaceletHandler> variableDeclarationHandlers);  }### Answer:
@Test public void shouldApply() throws Exception { FaceletHandler handler = mock(ComponentHandler.class); List<FaceletHandler> variableDeclarationHandlers = new ArrayList<FaceletHandler>(); DecoratedChild decorated = this.delegate.createdDecoratedChild(handler, variableDeclarationHandlers); decorated.apply(this.ctx, this.parent, "template"); verify(this.ctx).pushClient(this.templateClient.capture()); verify(this.ctx).includeFacelet(this.parent, "template"); this.templateClient.getValue().apply(this.ctx, this.parent, null); verify(handler).apply(this.ctx, this.parent); verify(this.ctx).popClient(this.templateClient.getValue()); }
@Test public void shouldApplyDefine() throws Exception { FaceletHandler handler = mock(ComponentHandler.class); List<FaceletHandler> variableDeclarationHandlers = new ArrayList<FaceletHandler>(); variableDeclarationHandlers.add(mockDefineHandler()); DecoratedChild decorated = this.delegate.createdDecoratedChild(handler, variableDeclarationHandlers); decorated.apply(this.ctx, this.parent, "template"); verify(this.ctx).pushClient(this.templateClient.capture()); this.templateClient.getValue().apply(this.ctx, this.parent, "defineName"); verify(this.innerDefineHandler).apply(this.ctx, this.parent); }
@Test public void shouldApplyParameters() throws Exception { FaceletHandler handler = mock(ComponentHandler.class); List<FaceletHandler> variableDeclarationHandlers = new ArrayList<FaceletHandler>(); FaceletHandler paramHandler = mock(ParamHandler.class); variableDeclarationHandlers.add(paramHandler); VariableMapper originalVariableMapper = mock(VariableMapper.class); given(this.ctx.getVariableMapper()).willReturn(originalVariableMapper); DecoratedChild decorated = this.delegate.createdDecoratedChild(handler, variableDeclarationHandlers); decorated.apply(this.ctx, this.parent, null); verify(this.ctx, times(2)).setVariableMapper(this.variableMapper.capture()); assertThat(this.variableMapper.getAllValues().get(0), is(VariableMapperWrapper.class)); assertThat(this.variableMapper.getAllValues().get(1), is(sameInstance(originalVariableMapper))); verify(paramHandler).apply(this.ctx, this.parent); }