Traits implements TraitIterable { @Override public Iterator<Trait> iterator() { return traits.iterator(); } Traits();  Traits(Trait trait);  Traits(Collection<Trait> traits); void add(Trait trait); @Override Iterator<Trait> iterator();  }
@Test public void startsOffEmpty() throws Exception { Traits traits = new Traits(); assertThat(traits.iterator().hasNext(), is(false)); }
@Test public void hasSingleTraitIfCreatedThatWay() throws Exception { Traits single = new Traits(secondTrait); Iterator<Trait> iterator = single.iterator(); iterator.next(); assertThat(iterator.hasNext(), is(false)); }
@Test public void hasTraitsFromListIfCreatedThatWay() throws Exception { List<Trait> traitList = Lists.newArrayList(firstTrait, secondTrait); Traits fromList = new Traits(traitList); Iterator<Trait> iterator = fromList.iterator(); assertThat(iterator.next(), is(firstTrait)); assertThat(iterator.next(), is(secondTrait)); }