### Question:
ReaderTGFF { protected void importTaskGraph(String name, Iterator<String> it, Application<Task, Dependency> application) { String id = CONNECTOR + name.split(SEPARATOR)[1]; String line = ""; double period = -1; while (!isClosing(line) && it.hasNext()) { line = it.next(); if (!isComment(line)) { if (line.contains(PERIOD)) { period = Double.parseDouble(line.replace(PERIOD, "").replaceAll(SEPARATOR, "")); } else if (line.contains(TASK)) { addTask(line, id, period, application); } else if (line.contains(ARC)) { addCommunication(line, id, period, application); } else if (line.contains(HARD_DEADLINE)) { addDeadline(line, id, application, HARD_DEADLINE); } else if (line.contains(SOFT_DEADLINE)) { addDeadline(line, id, application, SOFT_DEADLINE); } } } }  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; }### Answer:
@Test public void testImportTaskGraph() { List<String> in = Arrays.asList("PERIOD 300", "TASK t0_0 TYPE 1", "TASK t0_1 TYPE 2", "TASK t0_2 TYPE 2", "TASK t0_3 TYPE 2", "# a comment", "ARC a0_0 FROM t0_0 TO t0_1 TYPE 0", "ARC a0_1 FROM t0_1 TO t0_2 TYPE 0", "ARC a0_2 FROM t0_0 TO t0_3 TYPE 1", "HARD_DEADLINE d0_0 ON t0_2 AT 300", "SOFT_DEADLINE d0_1 ON t0_3 AT 200", "}"); Iterator<String> it = in.iterator(); Application<Task, Dependency> application = new Application<Task, Dependency>(); String line = "@TASK_GRAPH 0 test"; new ReaderTGFF().importTaskGraph(line, it, application); Assert.assertNotNull(application); Assert.assertEquals(7, application.getVertexCount()); Assert.assertEquals(6, application.getEdgeCount()); List<String> ids = new ArrayList<String>( Arrays.asList("t0_0_0", "t0_1_0", "t0_2_0", "t0_3_0", "a0_0", "a0_1", "a0_2")); for (Task task : application.getVertices()) { Assert.assertTrue(ids.contains(task.getId())); } List<String> edges = new ArrayList<String>( Arrays.asList("a0_0_0", "a0_0_1", "a0_1_0", "a0_1_1", "a0_2_0", "a0_2_1")); for (Dependency edge : application.getEdges()) { Assert.assertTrue(edges.contains(edge.getId())); } }