### Question:
Fork extends NodeBase { @Override public void addParent(final NodeBase parent) { Preconditions.checkState(this.parent == null, "Fork nodes cannot have multiple parents."); this.parent = parent; parent.addChild(this); } Fork(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 testAddParentWhenItAlreadyExistsThrows() { final NodeBase parent1 = getInstance("parent1"); final NodeBase parent2 = getInstance("parent2"); final Fork instance = getInstance("instance"); instance.addParent(parent1); expectedException.expect(IllegalStateException.class); instance.addParent(parent2); }