### Question:
ExplicitNode extends NodeBase { @Override public void addParent(final NodeBase parent) { Preconditions.checkState(this.parent == null, "An explicit node cannot have multiple parents."); this.parent = parent; parent.addChild(this); } ExplicitNode(final String name, final Node realNode); Node getRealNode(); NodeBase getParent(); NodeBase getChild(); @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 testAddingParentWhenItAlreadyExistsThrows() { final NodeBase parent1 = getInstance("parent1"); final NodeBase parent2 = getInstance("parent2"); final ExplicitNode instance = getInstance("instance"); instance.addParent(parent1); expectedException.expect(IllegalStateException.class); instance.addParent(parent2); }
@Test public void testNormalAddedAsParentWhenItAlreadyHasAChildThrows() { final ExplicitNode instance = getInstance("instance"); final NodeBase child1 = new ExplicitNode("child1", null); final NodeBase child2 = new ExplicitNode("child2", null); child1.addParent(instance); expectedException.expect(IllegalStateException.class); child2.addParent(instance); }