### Question:
SparkValueFunction implements ValueFunction { @Override public double convert(String name, double v) { for (NameMatcher matcher : matchers) { if (matcher.matches(name)) { return matcher.apply(v); } } return v; } private  SparkValueFunction(List<NameMatcher> matchers); static SparkValueFunction fromConfig(Config config); static SparkValueFunction fromConfig(Config config, String key); @Override double convert(String name, double v);  }### Answer:
@Test public void executorName() { final String name = "app-20150309231421-0000.0.executor.filesystem.file.largeRead_ops"; Assertions.assertEquals(42.0, f.convert(name, 42.0), 1e-12); }
@Test public void driverName() { final String name = "app-20150309231421-0000.driver.BlockManager.disk.diskSpaceUsed_MB"; Assertions.assertEquals(42.0 * 1e6, f.convert(name, 42.0), 1e-12); }
@Test public void driverStreamingTime() { final String name = "97278898-4bd4-49c2-9889-aa5f969a7816-0129.driver.HdfsWordCount.StreamingMetrics.streaming.lastCompletedBatch_processingEndTime"; Assertions.assertEquals(42.0 / 1000.0, f.convert(name, 42.0), 1e-12); }
@Test public void driverStreamingDelay() { final String name = "app-20150527224111-0014.<driver>.SubscriptionEnded.StreamingMetrics.streaming.lastReceivedBatch_submissionDelay"; Assertions.assertEquals(42.0 / 1000.0, f.convert(name, 42.0), 1e-12); }
@Test public void driverStreamingDelayAbnormal() { final String name = "app-20150527224111-0014.<driver>.SubscriptionEnded.StreamingMetrics.streaming.lastReceivedBatch_submissionDelay"; Assertions.assertEquals(Double.NaN, f.convert(name, -1.0), 1e-12); }