### Question:
DefaultComponentInfo implements ComponentInfo { public String getLabel() { UIComponent component = getComponent(); return (String) (component == null ? null : component.getAttributes().get("label")); } DefaultComponentInfo(FacesContext context, List<UIComponent> components); UIComponent getComponent(); List<UIComponent> getComponents(); boolean isValid(); boolean isRequired(); String getLabel(); String getFor();  }### Answer:
@Test public void shouldGetNullLabelIfNoComponents() throws Exception { ComponentInfo info = new DefaultComponentInfo(this.context, NO_COMPONENTS); assertThat(info.getLabel(), is(nullValue())); }
@Test public void shouldGetLabelFromFirstComponent() throws Exception { List<UIComponent> components = createComponents(2); given(components.get(0).getAttributes()).willReturn( Collections.<String, Object> singletonMap("label", "component1")); given(components.get(1).getAttributes()).willReturn( Collections.<String, Object> singletonMap("label", "component2")); ComponentInfo info = new DefaultComponentInfo(this.context, components); assertThat(info.getLabel(), is("component1")); }