ReaderTGFF { protected void importCore(String name, Iterator<String> it, ResourceTypes<Resource> resourceTypes) { String id = "r" + name.split(SEPARATOR)[1]; Resource res = new Resource(id); String[] resAttributes; resAttributes = (it.next()).replace(COMMENT, "").trim().split(SEPARATOR); String[] resValues = it.next().trim().split(SEPARATOR); assert resAttributes.length == resValues.length : "tgff-file \"" + CORE + "\": number of values is not " + "equal to required number of resource attributes"; for (int i = 0; i < resAttributes.length; i++) { res.setAttribute(resAttributes[i], Double.valueOf(resValues[i])); } resourceTypes.put(id, res); }  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 testImportCore() { ResourceTypes<Resource> resourceTypes = new ResourceTypes<Resource>(); String name = "@CORE 0 test"; List<String> in = Arrays.asList("# 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", "}"); Iterator<String> it = in.iterator(); ReaderTGFF reader = new ReaderTGFF(); reader.importCore(name, it, resourceTypes); String id = "r0"; Assert.assertEquals(1, resourceTypes.size()); Assert.assertTrue(resourceTypes.containsKey(id)); Resource resource = resourceTypes.get(id); Assert.assertEquals(79.0597, resource.getAttribute("price")); Assert.assertEquals(0.219023, resource.getAttribute("area")); }