### Question:
Sequence implements Iterable<SequenceItem> { public BayesianNetwork toBayesianNetwork() { if (containedItems.size() == 0) { throw new RuntimeException("Bayesian Network construction failed because the Sequence contains no SequenceItems"); } Optional<Vertex<?, ?>> seedVertex = containedItems .get(0) .getContents() .values() .stream() .findFirst(); if (!seedVertex.isPresent()) { throw new RuntimeException("Bayesian Network construction failed because there are no vertices in the Sequence"); } return new BayesianNetwork(seedVertex.get().getConnectedGraph()); } Sequence(int reservedSize, int uniqueIdentifier, String name); int getUniqueIdentifier(); String getName(); int size(); void add(SequenceItem p); List<SequenceItem> asList(); @NotNull @Override Iterator<SequenceItem> iterator(); SequenceItem getLastItem(); BayesianNetwork toBayesianNetwork();  }### Answer:
@Test public void bayesNetConstructionFailsWhenThereAreNoSequenceItems() { expectedException.expect(RuntimeException.class); expectedException.expectMessage("Bayesian Network construction failed because the Sequence contains no SequenceItems"); Sequence sequence = new Sequence(0, this.hashCode(), null); BayesianNetwork network = sequence.toBayesianNetwork(); }