### Question:
ExporterUtil { public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; } private  ExporterUtil(); static Double convertNanosTo(Double value, String unit); static final long NANOS_PER_MICROSECOND; static final long NANOS_PER_MILLI; static final long NANOS_PER_SECOND; static final long NANOS_PER_MINUTE; static final long NANOS_PER_HOUR; static final long NANOS_PER_DAY; }### Answer:
@Test public void shouldScaleNanosToSecods() { Double out = ExporterUtil.convertNanosTo(1.0, MetricUnits.MINUTES); Assert.assertEquals(out, 0.0, 1e-10); }
@Test public void shouldScaleNanosToMillis() { Double out = ExporterUtil.convertNanosTo(1.0, MetricUnits.MILLISECONDS); Assert.assertEquals(out, 0.000001, 1e-10); }
@Test public void testScaleHoursToSeconds() { String foo = MetricUnits.HOURS; Double out = ExporterUtil.convertNanosTo(3 * 3600 * 1000_000_000., foo); Assert.assertEquals(out, 3., 1e-10); }