ValuesInSIUnits { public static double convertDuration(double duration, TimeUnit sourceUnit) { return duration * getTimeUnitAsSeconds(sourceUnit); } private  ValuesInSIUnits(); static double convertDuration(double duration, TimeUnit sourceUnit); static double convertSpeed(double speed, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit); static double convertAcceleration(double acceleration, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit); static double convertJerk(double jerk, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit);  }
@Test void convertDuration_whenValueGetsLarger_thenPrecisionIsMaintained() { double minuteDuration = 1.31211; double siDuration = minuteDuration * 60; assertThat(ValuesInSIUnits.convertDuration(minuteDuration, TimeUnit.MINUTES)).isCloseTo(siDuration, withinPercentage(TOLERANCE)); }
@Test void convertDuration_whenValueGetsSmaller_thenPrecisionIsMaintained() { double millisecondDuration = 1.31211; double siDuration = millisecondDuration / 1000; assertThat(ValuesInSIUnits.convertDuration(millisecondDuration, TimeUnit.MILLISECONDS)).isCloseTo(siDuration, withinPercentage(TOLERANCE)); }