private void callRightLifecycleMethodGivenPhaseId(UIViewRoot root, PhaseId phaseId)
     throws Exception {
   if (phaseId.getOrdinal() == PhaseId.APPLY_REQUEST_VALUES.getOrdinal()) {
     root.processDecodes(facesContext);
   } else if (phaseId.getOrdinal() == PhaseId.PROCESS_VALIDATIONS.getOrdinal()) {
     root.processValidators(facesContext);
   } else if (phaseId.getOrdinal() == PhaseId.UPDATE_MODEL_VALUES.getOrdinal()) {
     root.processUpdates(facesContext);
   } else if (phaseId.getOrdinal() == PhaseId.INVOKE_APPLICATION.getOrdinal()) {
     root.processApplication(facesContext);
   } else if (phaseId.getOrdinal() == PhaseId.RENDER_RESPONSE.getOrdinal()) {
     root.encodeBegin(facesContext);
     root.encodeEnd(facesContext);
   }
 }
 private void checkEventQueuesSizes(
     List<List> events,
     int applyEventsSize,
     int valEventsSize,
     int updateEventsSize,
     int appEventsSize) {
   List applyEvents = events.get(PhaseId.APPLY_REQUEST_VALUES.getOrdinal());
   assertEquals("Apply-Request-Values Event Count", applyEventsSize, applyEvents.size());
   List valEvents = events.get(PhaseId.PROCESS_VALIDATIONS.getOrdinal());
   assertEquals("Process-Validations Event Count", valEventsSize, valEvents.size());
   List updateEvents = events.get(PhaseId.UPDATE_MODEL_VALUES.getOrdinal());
   assertEquals("Update-Model Event Count", updateEventsSize, updateEvents.size());
   List appEvents = events.get(PhaseId.INVOKE_APPLICATION.getOrdinal());
   assertEquals("Invoke-Application Event Count", appEventsSize, appEvents.size());
 }