ReaderTGFF { protected Mappings<Task, Resource> toMappings(List<String> in, ResourceTypes<Resource> resourceTypes) { Mappings<Task, Resource> mappings = new Mappings<Task, Resource>(); Iterator<String> it = in.iterator(); String currentLine; while (it.hasNext()) { currentLine = it.next(); if (currentLine.contains(CORE) || currentLine.contains(PROC) || currentLine.contains(CLIENT_PE) || currentLine.contains(SERVER_PE)) { importMappings(currentLine, it, resourceTypes, mappings); } } return mappings; }  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 testToMappings() { List<String> in = Arrays.asList("@HYPERPERIOD 300", "@COMMUN_QUANT 0 {", "# type quantity", "0 5", "1 6", "}", "@TASK_GRAPH 0 {", "PERIOD 300", "TASK t0_0 TYPE 1", "TASK t0_1 TYPE 2", "TASK t0_2 TYPE 2", "TASK t0_3 TYPE 2", "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", "}", "@CORE 0 {", "# price area", "79.0597 0.219023", "#-----------", "# type version valid task_time", "0 0 1 10", "1 0 1 7", "2 0 1 11", "}", "@CORE 1 {", "# price area", "72.405 0.166029", "#-----------", "# type version valid task_time", "0 0 1 8", "1 0 0 9", "2 0 1 11", "}", "@CORE 2 {", "# price area", "97.0382 0.185649", "#-----------", "# type version valid task_time", "0 0 1 10", "1 0 0 8", "2 0 1 12", "}", "@WIRING 0", "{", "# max_buffer_size", "491", "}"); ReaderTGFF reader = new ReaderTGFF(); reader.toApplication(in); ResourceTypes<Resource> resourceTypes = reader.toResourceTypes(in); Mappings<Task, Resource> mappings = reader.toMappings(in, resourceTypes); Assert.assertEquals(10, mappings.size()); List<String> ids = new ArrayList<String>( Arrays.asList("m_t0_0_0_r0", "m_t0_1_0_r0", "m_t0_2_0_r0", "m_t0_3_0_r0", "m_t0_1_0_r1", "m_t0_2_0_r1", "m_t0_3_0_r1", "m_t0_1_0_r2", "m_t0_2_0_r2", "m_t0_3_0_r2")); List<Double> times = new ArrayList<Double>(Arrays.asList(7.0, 8.0, 9.0, 11.0, 12.0)); for (Mapping<Task, Resource> mapping : mappings) { Assert.assertTrue(ids.contains(mapping.getId())); Assert.assertTrue(times.contains(mapping.getAttribute("task_time"))); } }