MetricFrameLoader { public static MetricFrame loadCsv(File metricDefFile, File metricDataFile, boolean hasHeader) throws IOException { val metricDef = OBJECT_MAPPER.readValue(metricDefFile, MetricDefinition.class); FileInputStream fileInputStream = new FileInputStream(metricDataFile); try { return loadCsv(metricDef, fileInputStream, hasHeader); } finally { if (fileInputStream != null) { safeClose(fileInputStream); } } }  static MetricFrame loadCsv(File metricDefFile, File metricDataFile, boolean hasHeader); static MetricFrame loadCsv(MetricDefinition metricDef, InputStream in, boolean hasHeader);  }
@Test public void testLoadCsv_files() throws Exception { val defFile = getResourceAsFile(DEF_FILENAME); val dataFile = getResourceAsFile(DATA_FILENAME); log.info("defFile={}, dataFile={}", defFile, dataFile); val frame = MetricFrameLoader.loadCsv(defFile, dataFile, true); assertEquals(5040, frame.getNumRows()); assertEquals(9.0, frame.getMetricData().get(118).getValue(), 0.001); }
@Test public void testLoadCsv() throws Exception { val metric = new MetricDefinition(new TagCollection(new HashMap<String, String>() {{ put("unit", "dummy"); put("mtype", "dummy"); }})); val is = ClassLoader.getSystemResourceAsStream(DATA_FILENAME); val frame = MetricFrameLoader.loadCsv(metric, is, true); assertNotNull(frame); assertTrue(frame.getNumRows() > 0); assertEquals(0.0, frame.getMetricDataPoint(0).getValue(), TOLERANCE); assertEquals(3.0, frame.getMetricDataPoint(15).getValue(), TOLERANCE); }