/** * Expect a list of metrics with specific values. * Fail if not all metrics are received, or some metric has the wrong value. * @param report MetricReport. * @param expected map of expected metric names and their values * @throws IOException */ private void expectMetricsWithValues(MetricReport report, Map<String, Double> expected) throws IOException { List<Metric> metricIterator = report.getMetrics(); for (Metric metric : metricIterator) { if (expected.containsKey(metric.getName())) { Assert.assertEquals(expected.get(metric.getName()), metric.getValue()); expected.remove(metric.getName()); } } Assert.assertTrue(expected.isEmpty()); }