### Question:
StateDiagramGenerator { public File generateFrom(Document radl, File dir, File configuration) { return generateFrom(radl, new JGraphStateDiagram(), dir, configuration); }  File generateFrom(Document radl, File dir, File configuration);  }### Answer:
@Test public void generatesImageFromStateDiagram() throws FileNotFoundException { String prefix = "$rel"; File configuration = new File(someName() + ".properties"); String linkRelationsUriPrefix = "urn:radl:" + someName(); try (PrintWriter writer = new PrintWriter(configuration, "UTF8")) { writer.println("prefixes = " + prefix + '=' + linkRelationsUriPrefix); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } String service = someName(); String homeState = "Start"; String homeTransition = someTransition(); String state1 = someState(); String state2 = someState(); String transition = someTransition(); String linkRelation = someLinkRelation(); String homeUri = "/"; String homeMethod = "GET"; String method = "POST"; Document radl = DocumentBuilder.newDocument() .namespace(Radl.NAMESPACE_URI) .element("service") .attribute("name", service) .element("states") .element("start-state") .element("transitions") .element("transition") .attribute("name", homeTransition) .attribute("to", state1) .end() .end() .end() .element("state") .attribute("name", state1) .element("transitions") .element("transition") .attribute("name", transition) .attribute("to", state2) .end() .end() .end() .element("state") .attribute("name", state2) .end() .end() .element("link-relations") .element("link-relation") .attribute("name", linkRelationsUriPrefix + linkRelation) .element("transitions") .element("transition") .attribute("name", transition) .end() .end() .end() .end() .element("resources") .element("resource") .element("location") .attribute("uri", homeUri) .end() .element("methods") .element("method") .attribute("name", homeMethod) .element("transitions") .element("transition") .attribute("name", homeTransition) .end() .end() .end() .element("method") .attribute("name", method) .element("transitions") .element("transition") .attribute("name", transition) .end() .end() .end() .end() .end() .end() .end() .build(); File dir = new File(DIR, someName()); File image = new File(dir, "states.png"); StateDiagram diagram = mock(StateDiagram.class); try { generator.generateFrom(radl, diagram, dir, configuration); verify(diagram).addStartState(homeState); verify(diagram).addState(state1); verify(diagram).addTransition("Start", state1, homeMethod + ' ' + homeUri); verify(diagram).addState(state2); verify(diagram).addTransition(state1, state2, method + NL + prefix + linkRelation); verify(diagram).toImage(eq(image)); } finally { IO.delete(configuration); } }