SpecificationReader { protected void parseDependency(nu.xom.Element eDependency, Application<Task, Dependency> application) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Dependency dependency = toEdge(eDependency, null); String srcName = eDependency.getAttributeValue("source"); Task source = application.getVertex(srcName); if (source == null) { throw new IllegalArgumentException("Source of dependency " + srcName + " not found: " + srcName); } String dstName = eDependency.getAttributeValue("destination"); Task destination = application.getVertex(dstName); if (destination == null) { throw new IllegalArgumentException("Destination of dependency " + dependency + " not found: " + dstName); } application.addEdge(dependency, source, destination, EdgeType.DIRECTED); }  Specification read(String filename); Specification read(File file); Specification read(InputStream in); Specification toSpecification(nu.xom.Element eSpecification);  }
@Test public void parseDependencyTest() throws ValidityException, ParsingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { nu.xom.Element eLink = new Builder() .build("<dependency id='d1' source='t1' destination='c1' orientation='DIRECTED'/>", "") .getRootElement(); Application<Task, Dependency> application = new Application<Task, Dependency>(); Task d1 = new Task("t1"); Task d2 = new Task("c1"); application.addVertex(d1); application.addVertex(d2); SpecificationReader r = new SpecificationReader(); r.parseDependency(eLink, application); Assert.assertTrue(application.isSuccessor(d1, d2)); }
@Test(expected = IllegalArgumentException.class) public void parseDependencySrcMissingTest() throws ValidityException, ParsingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { nu.xom.Element eLink = new Builder() .build("<dependency id='d1' source='t1' destination='c1' orientation='DIRECTED'/>", "") .getRootElement(); Application<Task, Dependency> application = new Application<Task, Dependency>(); Task d2 = new Task("c1"); application.addVertex(d2); SpecificationReader r = new SpecificationReader(); r.parseDependency(eLink, application); }
@Test(expected = IllegalArgumentException.class) public void parseDependencyDstMissingTest() throws ValidityException, ParsingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { nu.xom.Element eLink = new Builder() .build("<dependency id='d1' source='t1' destination='c1' orientation='DIRECTED'/>", "") .getRootElement(); Application<Task, Dependency> application = new Application<Task, Dependency>(); Task d1 = new Task("t1"); application.addVertex(d1); SpecificationReader r = new SpecificationReader(); r.parseDependency(eLink, application); }