SequenceForwardOrder { protected NodeData findInput() { NodeData found = null; for (int i = 0; i < sequence.size(); i++) { NodeData n = sequence.get(i); if( n.node.sources.isEmpty() ) { if( found != null ) throw new RuntimeException("Found multiple input nodes"); found = n; } } if( found == null ) throw new RuntimeException("No input node found"); return found; } SequenceForwardOrder(List<Node<?,?>> list ); List<Node<?,?>> putIntoForwardOrder();  }
@Test public void findInput() { for (int i = 1; i < 4; i++) { List<Node> list = createLineSequence(i); Node first = list.get(0); Collections.shuffle(list,rand); SequenceForwardOrder alg = new SequenceForwardOrder((List)list); assertTrue(first == alg.findInput().node); } }