### Question:
FacesUtils { @SuppressWarnings("unchecked") public static <T> T findParentOfType(UIComponent component, Class<T> parentType) { Assert.notNull(component, "Component must not be null"); Assert.notNull(parentType, "ParentType must not be null"); UIComponent current = component.getParent(); while (current != null) { if (parentType.isInstance(current)) { return (T) current; } current = current.getParent(); } return null; }  static Locale getLocale(FacesContext context); @SuppressWarnings("unchecked") static T findParentOfType(UIComponent component, Class<T> parentType); static V doWithRequestScopeVariable(FacesContext context, String variableName, Object value,
			Callable<V> callable); static void doWithRequestScopeVariable(FacesContext context, String variableName, Object value,
			final Runnable runnable);  }### Answer:
@Test public void shouldNeedComponentForFindParentOfType() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("Component must not be null"); FacesUtils.findParentOfType(null, UIPanel.class); }
@Test public void shouldNeedParentTyoeFirFindParentIfType() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("ParentType must not be null"); FacesUtils.findParentOfType(new UIInput(), null); }
@Test public void shouldFindParentOfType() throws Exception { UIPanel p1 = new UIPanel(); UIPanel p2 = new UIPanel(); UIInput input = new UIInput(); p2.setParent(p1); input.setParent(p2); UIPanel actual = FacesUtils.findParentOfType(input, UIPanel.class); assertThat(actual, is(sameInstance(p2))); }
@Test public void shouldReturnNullIfNotSuitableParent() throws Exception { UIPanel p1 = new UIPanel(); UIInput input = new UIInput(); input.setParent(p1); UIRepeat actual = FacesUtils.findParentOfType(input, UIRepeat.class); assertThat(actual, is(nullValue())); }