bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class));
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>()
{
public Object answer()
{
ComponentSystemEvent e = (ComponentSystemEvent) EasyMock
.getCurrentArguments()[0];
Assert.assertTrue(e.getComponent() instanceof UIViewRoot);
Assert.assertEquals(PhaseId.RENDER_RESPONSE, facesContext.getCurrentPhaseId());
return null;
}
}).once();
EasyMock.replay(bean);
//Put on request map
request.setAttribute("postAddToViewEventBean", bean);
processLifecycleExecuteAndRender();
EasyMock.verify(bean);
UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
submit(button);
bean = EasyMock.createMock(PostAddToViewEventBean.class);
bean.invokePostAddToViewEvent(EasyMock.isA(ComponentSystemEvent.class));
// With PSS PostAddToViewEvent is called again on restore view phase
// but when building initial state.
if (WebConfigParamUtils.getBooleanInitParameter(externalContext, StateManager.PARTIAL_STATE_SAVING_PARAM_NAME))
{
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>()
{
public Object answer()
{
ComponentSystemEvent e = (ComponentSystemEvent) EasyMock
.getCurrentArguments()[0];
Assert.assertTrue(e.getComponent() instanceof UIViewRoot);
Assert.assertEquals(PhaseId.RESTORE_VIEW, facesContext.getCurrentPhaseId());
Assert.assertTrue(facesContext.getAttributes().containsKey("javax.faces.IS_BUILDING_INITIAL_STATE"));
Assert.assertFalse(FaceletViewDeclarationLanguage.isRefreshingTransientBuild(facesContext));
return null;
}