BranchesList implements Iterable<Branch> { public void bloomFrom(Branch branch) { if (list.size() < MAX_BRANCHES && branch.canBloom() && flowerOptionPreferences.getFlower() != Flower.NONE) { list.add(Branch.createFrom(branch)); } } BranchesList(List<Branch> list, FlowerOptionPreferences flowerOptionPreferences); static BranchesList newInstance(); void bloomFrom(Branch branch); @Override Iterator<Branch> iterator(); void prune(Branch branch); void clear(); List<Branch> asList();  }
@Test public void testThatWhenFlowerIsNoneAndNotEnoughOnListThenFlowerIsNotIncludedIntoList() { givenThatSelectedFlowerIsNone(); branchesList.bloomFrom(Branch.createAt(0, 0)); Assertions.assertThat(branchesList).hasSize(0); }
@Test public void testThatWhenFlowerIsOtherThanNoneAndEnoughOnListThenFlowerIsNotIncludedIntoList() { givenThatHasEnoughBranches(); Assertions.assertThat(branchesList).hasSize(MAX_BRANCHES); branchesList.bloomFrom(Branch.createAt(0, 0)); Assertions.assertThat(branchesList).hasSize(MAX_BRANCHES); }
@Test public void testThatWhenFlowerIsOtherThanNoneAndNotEnoughOnListThenFlowerIsNotIncludedIntoListIfBranchCantBloom() { Branch branch = givenABranchThatCannotBloom(); branchesList.bloomFrom(branch); Assertions.assertThat(branchesList).hasSize(0); }