### Question:
End extends NodeBase { @Override public void addParent(final NodeBase parent) { Preconditions.checkState(this.parent == null, "End nodes cannot have multiple parents."); this.parent = parent; parent.addChild(this); } End(final String name); NodeBase getParent(); @Override void addParent(final NodeBase parent); @Override void addParentWithCondition(final Decision parent, final Condition condition); @Override void addParentDefaultConditional(Decision parent); @Override void removeParent(final NodeBase parent); @Override void clearParents(); @Override List<NodeBase> getChildren();  }### Answer:
@Test public void testAddParentWhenItAlreadyExists() { final Start parent1 = new Start("parent1"); final Start parent2 = new Start("parent2"); final End instance = getInstance("instance"); instance.addParent(parent1); expectedException.expect(IllegalStateException.class); instance.addParent(parent2); }
@Test public void testAddedAsParentThrows () { final End instance = getInstance("instance"); final ExplicitNode child = new ExplicitNode("child", null); expectedException.expect(IllegalStateException.class); child.addParent(instance); }