this.springFacesContext.render(view, model);
}
@Test
public void shouldSetViewRootIfDoubleRendering() throws Exception {
FacesView view = mock(FacesView.class);
given(view.getViewArtifact()).willReturn(new ViewArtifact("theartifact"));
final Map<String, Object> model = new HashMap<String, Object>();
Application application = mock(Application.class);
ViewHandler viewHandler = mock(ViewHandler.class);
final UIViewRoot newViewRoot = mock(UIViewRoot.class);
given(this.facesContext.getApplication()).willReturn(application);
given(application.getViewHandler()).willReturn(viewHandler);
given(viewHandler.createView(any(FacesContext.class), eq("newartifact"))).willReturn(newViewRoot);
Lifecycle lifecycle = mock(Lifecycle.class);
given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle);
willAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) throws Throwable {
FacesView view2 = mock(FacesView.class);
given(view2.getViewArtifact()).willReturn(new ViewArtifact("newartifact"));
DefaultSpringFacesContextTest.this.springFacesContext.render(view2, model);
verify(DefaultSpringFacesContextTest.this.facesContext).setViewRoot(newViewRoot);
return null;
}
}).given(lifecycle).render((FacesContext) any());