### Question:
SelectItems implements Iterable<SelectItem> { protected final Object getValue() { return this.value; } SelectItems(Object value); @SuppressWarnings({ "rawtypes", "unchecked" }) Iterator<SelectItem> iterator();  }### Answer:
@Test public void shouldSupportMap() throws Exception { Map<Object, Object> map = new LinkedHashMap<Object, Object>(); map.put("ka", "va"); map.put(null, "vb"); map.put("c", null); Iterator<SelectItem> iterator = newSelectItemsIterator(map); SelectItem a = iterator.next(); SelectItem b = iterator.next(); SelectItem c = iterator.next(); assertThat(iterator.hasNext(), is(false)); assertThat(a.getLabel(), is("ka")); assertThat(a.getValue(), is((Object) "va")); assertThat(b.getLabel(), is("vb")); assertThat(b.getValue(), is((Object) "vb")); assertThat(c.getLabel(), is("c")); assertThat(c.getValue(), is((Object) "")); }
@Test public void shouldSupportArrayOfObjects() throws Exception { Iterator<SelectItem> iterator = newSelectItemsIterator(new String[] { "a", "b" }); assertThat(iterator.next().getValue(), is((Object) "a")); assertThat(iterator.next().getValue(), is((Object) "b")); assertThat(iterator.hasNext(), is(false)); }
@Test public void shouldSupportIterableOfObjects() throws Exception { Iterator<SelectItem> iterator = newSelectItemsIterator(Arrays.asList("a", "b")); assertThat(iterator.next().getValue(), is((Object) "a")); assertThat(iterator.next().getValue(), is((Object) "b")); assertThat(iterator.hasNext(), is(false)); }
@Test public void shouldGetValue() throws Exception { final SelectItem value = new SelectItem(); new TestableSelectItems(value) { @Override public void test() throws Exception { assertThat(getValue(), is(sameInstance((Object) value))); } }.test(); }