### Question:
DefaultComponentInfo implements ComponentInfo { public boolean isRequired() { for (UIComponent component : this.components) { if (isRequired(component)) { return true; } } return false; } DefaultComponentInfo(FacesContext context, List<UIComponent> components); UIComponent getComponent(); List<UIComponent> getComponents(); boolean isValid(); boolean isRequired(); String getLabel(); String getFor();  }### Answer:
@Test public void shouldNotBeRequiredIfNoneAreRequired() throws Exception { List<UIComponent> components = createComponents(3); ComponentInfo info = new DefaultComponentInfo(this.context, components); assertThat(info.isRequired(), is(false)); }
@Test public void shouldBeRequiredIfAnyAreRequired() throws Exception { List<UIComponent> components = createComponents(3); given(((EditableValueHolder) components.get(2)).isRequired()).willReturn(true); components.add(2, mock(UIComponent.class)); ComponentInfo info = new DefaultComponentInfo(this.context, components); assertThat(info.isRequired(), is(true)); }
@Test public void shouldBeRequiredIfHasNotNullAnnotation() throws Exception { ComponentInfo info = getComponentInfoForBeanValue("notNull"); assertThat(info.isRequired(), is(true)); }
@Test public void shouldBeRequiredIfHasNotNullMetaAnnotation() throws Exception { ComponentInfo info = getComponentInfoForBeanValue("notBlank"); assertThat(info.isRequired(), is(true)); }
@Test public void shouldNotBeRequiredIfConstrainedButNotWithNotNull() throws Exception { ComponentInfo info = getComponentInfoForBeanValue("canBeNull"); assertThat(info.isRequired(), is(false)); }