List<MetricDisplaySummary> metricDisplaySummaries = new ArrayList<MetricDisplaySummary>();
Locale locale = Locale.US;
MessageResources messageResources = createMessageResources();
// test bits
MetricDisplaySummary a = createFakeMetric(1234567890.0987654321, MeasurementUnits.BITS);
MetricDisplaySummary b = createFakeMetric(1023, MeasurementUnits.BITS);
MetricDisplaySummary c = createFakeMetric(65536, MeasurementUnits.BITS);
MetricDisplaySummary d = createFakeMetric(0.1845, MeasurementUnits.MEGABITS);
metricDisplaySummaries.add(a);
metricDisplaySummaries.add(b);
metricDisplaySummaries.add(c);
metricDisplaySummaries.add(d);
Integer resourceCount = MonitorUtils.formatMetrics(metricDisplaySummaries, locale, messageResources);
assertEquals(nf.format(1.1)+"Gb", a.getAvgMetric().getValueFmt());
nf.setMinimumFractionDigits(1); // Otherwise NumberFormat swallows the fraction digit
assertEquals(nf.format(1023)+"b", b.getAvgMetric().getValueFmt());
assertEquals(nf.format(64)+"Kb", c.getAvgMetric().getValueFmt());
assertEquals(nf.format(188.9)+"Kb", d.getAvgMetric().getValueFmt());
}