### Question:
UISelectItems extends UIComponentBase { @Override public void setParent(UIComponent parent) { detatch(getParent()); super.setParent(parent); attatch(parent); }  @Override String getFamily(); @Override void setParent(UIComponent parent); String getVar(); void setVar(String var); Object getValue(); void setValue(Object value); Object getItemValue(); void setItemValue(Object itemValue); String getItemLabel(); void setItemLabel(String itemLabel); String getItemDescription(); void setItemDescription(String itemDescription); boolean isItemDisabled(); void setItemDisabled(boolean itemDisabled); boolean isItemLabelEscaped(); void setItemLabelEscaped(boolean itemLabelEscaped); String getItemConverterStringValue(); void setItemConverterStringValue(String converterStringValue); Object getNoSelectionValue(); void setNoSelectionValue(Object noSelectionValue); Boolean getIncludeNoSelectionOption(); void setIncludeNoSelectionOption(Boolean includeNoSelectionOption); MessageSource getMessageSource(); void setMessageSource(MessageSource messageSource); static final String NO_SELECTION_OPTION_MESSAGE_CODE; static final String NO_SELECTION_OPTION_DEFAULT_MESSAGE; static final String COMPONENT_FAMILY; }### Answer:
@Test public void shouldAddDelegateSelectItemsComponentOnAttach() throws Exception { UIComponent parent = mockParent(UIComponent.class); this.selectItems.setParent(parent); assertThat(parent.getChildren().get(0), is(ExposedUISelectItems.class)); }
@Test public void shouldNotReplaceExistingConverterOnAttach() throws Exception { UISelectMany parent = mockParent(UISelectMany.class); Converter converter = mock(Converter.class); given((parent).getConverter()).willReturn(converter); this.selectItems.setParent(parent); verify(parent, never()).setConverter(any(Converter.class)); }
@Test public void shouldRemoveDelegateSelectItemsComponentOnDetatch() throws Exception { UIComponent parent = mockParent(UIComponent.class); this.selectItems.setParent(parent); this.selectItems.setParent(mockParent(UIComponent.class)); assertThat(parent.getChildren().size(), is(0)); }
@Test public void shouldNotRemoveExistingConverterOnDetatch() throws Exception { UISelectMany parent = mockParent(UISelectMany.class); Converter converter = mock(Converter.class); given((parent).getConverter()).willReturn(converter); this.selectItems.setParent(parent); this.selectItems.setParent(mockParent(UISelectMany.class)); verify(parent, never()).setConverter(null); }