Job implements Serializable { public String toDotString() { StringBuilder builder = new StringBuilder(); builder.append("digraph {\n"); for (Connection connection : connections) { for (ConnectionEndPoint output : connection.outputs) { String edge = String.format(" %s -> %s [label=\"%s\"];\n", connection.input.getStageName(), output.getStageName(), connection.getName()); builder.append(edge); } } for (Stage stage : stages.values()) { builder.append(String.format(" %s;\n", stage.name)); } builder.append("}\n"); return builder.toString(); }  Job add(String jobName, Job group); Job add(Stage s); Job addMergeStage(String stageName, String pointName, int factor); Job connect(String sourceName, String destinationName, ConnectionAssignmentType assignment); Job connect(String sourceName, String destinationName, ConnectionAssignmentType assignment, int hashCount); Job connect(String sourceName, String destinationName, ConnectionAssignmentType assignment, String[] hashType); Job connect(String sourceName, String destinationName, ConnectionAssignmentType assignment, String[] hashType, int hashCount); Job connect(StagePoint source, StagePoint destination, ConnectionAssignmentType assignment, String[] hashType, int hashCount); String toDotString(); @Override String toString(); public TreeMap<String, Stage> stages; public ArrayList<Connection> connections; public HashMap<String, ConnectionEndPoint> exports; public HashMap<String, String> properties; }
@Test public void testToDotString() { Job job = new Job(); Stage a = new Stage("a"); a.add(new StageConnectionPoint(ConnectionPointType.Output, "c", new XMLFragment.NodePathOrder())); job.add(a); Stage b = new Stage("b"); b.add(new StageConnectionPoint(ConnectionPointType.Input, "c", new XMLFragment.NodePathOrder())); job.add(b); job.connect("a", "b", ConnectionAssignmentType.Combined); String expected = "digraph {\n" + " a -> b [label=\"a-c\"];\n" + " a;\n" + " b;\n" + "}\n"; assertEquals(expected, job.toDotString()); }