ReaderTGFF { protected void addDeadline(String line, String suffix, Application<Task, Dependency> application, String deadlineType) { String[] entries = line.trim().split(SEPARATOR); assert entries.length == 6 : "tgff-file \"" + deadlineType + "\": wrong number of entries"; Task t = application.getVertex(entries[3] + suffix); assert t != null : "error in tgff file: task " + entries[3] + " does not exist, so cannot be assigned a deadline."; t.setAttribute(deadlineType, Double.parseDouble(entries[5])); }  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 testAddDeadline() { String line = "HARD_DEADLINE d0_0 ON sink AT 0.0003"; String suffix = "_0"; Task task0 = new Task("sink_0"); Application<Task, Dependency> application = new Application<Task, Dependency>(); application.addVertex(task0); String deadlineType = ReaderTGFF.HARD_DEADLINE; ReaderTGFF reader = new ReaderTGFF(); reader.addDeadline(line, suffix, application, deadlineType); Assert.assertNotNull(application.iterator().next().getAttribute(deadlineType)); Assert.assertEquals(0.0003, application.iterator().next().getAttribute(deadlineType)); }
@Test(expected = AssertionError.class) public void testAddDeadlineInvalid() { String line = "HARD_DEADLINE d0_0 ON sink AT 0.0003 wrong_number_of_entries"; String suffix = "_0"; Task task0 = new Task("sink_0"); Application<Task, Dependency> application = new Application<Task, Dependency>(); application.addVertex(task0); String deadlineType = ReaderTGFF.HARD_DEADLINE; ReaderTGFF reader = new ReaderTGFF(); reader.addDeadline(line, suffix, application, deadlineType); }
@Test(expected = AssertionError.class) public void testAddDeadlineToNonExistantTask() { String line = "HARD_DEADLINE d0_0 ON sink AT 0.0003"; String suffix = "_0"; Application<Task, Dependency> application = new Application<Task, Dependency>(); new ReaderTGFF().addDeadline(line, suffix, application, ReaderTGFF.HARD_DEADLINE); }