DagBuilder { public Node createNode(final String name, final NodeProcessor nodeProcessor) { checkIsBuilt(); if (this.nameToNodeMap.get(name) != null) { throw new DagException(String.format("Node names in %s need to be unique. The name " + "(%s) already exists.", this, name)); } final Node node = new Node(name, nodeProcessor, this.dag); this.nameToNodeMap.put(name, node); return node; } DagBuilder(final String name, final DagProcessor dagProcessor); Node createNode(final String name, final NodeProcessor nodeProcessor); void addParentNode(final String childNodeName, final String parentNodeName); Dag build(); @Override String toString();  }
@Test public void create_nodes_with_same_name_should_throw_an_exception() { final String name = "nb"; createNode(name); final Throwable thrown = catchThrowable(() -> createNode(name)); assertThrownIsDagBuilderException(thrown); }