RendererUtils { public UIComponent getNestingForm(UIComponent component) { return getNestingForm(null, component); } protected  RendererUtils(); static RendererUtils getInstance(); void encodeId(FacesContext context, UIComponent component); void encodeId(FacesContext context, UIComponent component, String attribute); void encodeCustomId(FacesContext context, UIComponent component); Object createParameterValue(UIParameter parameter); Map<String, Object> createParametersMap(FacesContext context, UIComponent component); void encodePassThru(FacesContext context, UIComponent component, String defaultHtmlEvent); void encodePassThruWithExclusions(FacesContext context, UIComponent component, String exclusions,
        String defaultHtmlEvent); void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component, String[] exclusions,
        String defaultHtmlEvent); void encodePassThruAttribute(FacesContext context, Map<String, Object> attributes, ResponseWriter writer,
        String attribute); void encodeAttributesFromArray(FacesContext context, UIComponent component, String[] attrs); void encodeAttributes(FacesContext context, UIComponent component, String attrs); void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName); void encodeAttribute(FacesContext context, UIComponent component, String attribute); boolean isEmpty(Object o); boolean isBooleanAttribute(UIComponent component, String name); String encodePx(String value); String encodePctOrPx(String value); UIComponent getNestingForm(UIComponent component); @Deprecated UIComponent getNestingForm(FacesContext context, UIComponent component); UIComponent getSubmittedForm(FacesContext facesContext); boolean isFormSubmitted(FacesContext context, UIForm form); void encodeBeginFormIfNessesary(FacesContext context, UIComponent component); void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId); void encodeEndFormIfNessesary(FacesContext context, UIComponent component); static void writeState(FacesContext context); void encodeEndForm(FacesContext context, ResponseWriter writer); String getActionUrl(FacesContext facesContext); String clientId(FacesContext context, UIComponent component); void writeScript(FacesContext context, UIComponent component, Object script); String correctForIdReference(String forAttr, UIComponent component); void encodeChildren(FacesContext context, UIComponent component); boolean hasExplicitId(UIComponent component); UIComponent findComponentFor(FacesContext context, UIComponent component, String id); UIComponent findComponentFor(UIComponent component, String id); static final String DUMMY_FORM_ID; }
@Test public void when_getNestingForm_is_provided_with_component_which_has_form_ancestor_then_it_is_returned() { UIComponent form = mock(UIForm.class); UIComponent component1 = mock(UIComponent.class); UIComponent component2 = mock(UIComponent.class); when(component1.getParent()).thenReturn(component2); when(component2.getParent()).thenReturn(form); UIComponent result = utils.getNestingForm(component1); assertEquals(form, result); }
@Test public void when_getNestingForm_is_provided_with_component_which_hasnt_form_ancestor_then_null_is_returned() { UIComponent viewRoot = mock(UIViewRoot.class); UIComponent component1 = mock(UIComponent.class); UIComponent component2 = mock(UIComponent.class); when(component1.getParent()).thenReturn(component2); when(component2.getParent()).thenReturn(viewRoot); UIComponent result = utils.getNestingForm(component1); assertNull(result); }