ReaderTGFF { protected void addCommunication(String line, String suffix, double period, Application<Task, Dependency> application) { String[] entries = line.trim().split(SEPARATOR); assert entries.length == 8 : "tgff-file \"ARC\": wrong number of entries in line"; String id = entries[1]; String tgffType = entries[7]; Communication comm = new Communication(id); comm.setAttribute(PERIOD, period); comm.setAttribute(TGFF_TYPE, tgffType); if (messageSizes != null && messageSizes.containsKey(tgffType)) { comm.setAttribute(MSG_SIZE, messageSizes.get(entries[7])); } Task t1 = application.getVertex(entries[3] + suffix); Task t2 = application.getVertex(entries[5] + suffix); application.addVertex(comm); application.addEdge(new Dependency(id + "_0"), t1, comm); application.addEdge(new Dependency(id + "_1"), comm, t2); }  SpecificationTypeBased read(String filename); SpecificationTypeBased read(File file); SpecificationTypeBased read(InputStream in); SpecificationTypeBased toSpecification(List<String> in); static final String TGFF_TYPE; static final String PERIOD; static final String MSG_SIZE; static final String RES_ATTRIBUTES; static final String RES_VALUES; static final String HARD_DEADLINE; static final String SOFT_DEADLINE; static final String WIRE; }
@Test public void testAddCommunication() { String line = "ARC a0_0 FROM test0_0 TO test0_1 TYPE 0"; String suffix = "_0"; double period = 0.0; Task task0 = new Task("test0_0_0"); Task task1 = new Task("test0_1_0"); Application<Task, Dependency> application = new Application<Task, Dependency>(); application.addVertex(task0); application.addVertex(task1); ReaderTGFF reader = new ReaderTGFF(); List<String> in = Arrays.asList("# type quantity", "0 5", "1 6", "}"); Iterator<String> it = in.iterator(); reader.messageSizes = reader.importMessageSizes(it); reader.addCommunication(line, suffix, period, application); String comm = "a0_0"; Assert.assertEquals(3, application.getVertexCount()); Assert.assertNotNull(application.getVertex(comm)); Assert.assertEquals(2, application.getEdgeCount()); Assert.assertNotNull(application.getEdge(comm + "_0")); Assert.assertNotNull(application.getEdge(comm + "_1")); }