### Question:
ListBoxItem extends FormItem<String> implements ChoiceItem<String> { public ListBoxItem(String name, String title) { super(name, title); listBox = new ListBox(); listBox.setName(name); listBox.setTitle(title); listBox.setVisibleItemCount(1); listBox.setTabIndex(0); valueChangeHandler = new ChangeHandler() { @Override public void onChange(ChangeEvent event) { setModified(true); } }; listBox.addChangeHandler(valueChangeHandler); wrapper = new HorizontalPanel(); wrapper.add(listBox); } ListBoxItem(String name, String title); @Override Widget asWidget(); void setChoices(Collection<String> choices, String defaultChoice); @Override String getValue(); @Override void setValue(String value); @Override void setEnabled(boolean b); @Override boolean validate(String value); @Override void clearValue();  }### Answer:
@Test public void testListBoxItem() { ListBoxItem lbi = new ListBoxItem("listbox", "List Box"); assertEquals("listbox", lbi.getName()); assertEquals("List Box", lbi.getTitle()); HorizontalPanel panel = (HorizontalPanel) lbi.asWidget(); ListBox listBox = findListBox(panel); assertEquals(0, listBox.getItemCount()); lbi.setChoices(Arrays.asList("b", "a"), null); assertEquals(2, listBox.getItemCount()); assertEquals("a", listBox.getItemText(0)); assertEquals("b", listBox.getItemText(1)); assertNull(lbi.getValue()); try { lbi.setValue("c"); fail("Should have thrown an exception as 'c' is not one of the listbox values"); } catch (IllegalStateException ise) { } assertNull(lbi.getValue()); lbi.setValue("b"); assertEquals("b", lbi.getValue()); listBox.setSelectedIndex(0); assertEquals("a", lbi.getValue()); lbi.setChoices(Collections.singleton("d"), "d"); assertEquals(1, listBox.getItemCount()); assertEquals("d", listBox.getItemText(0)); assertEquals("d", lbi.getValue()); }