MathExt { public static double scale(double value, double min, double max) { Preconditions.checkArgument(min < max, "min must be less than max"); return (value - min) / (max - min); }  static double scale(double value, double min, double max); static double scale(double value, double min, double max, double minRangeValue, double maxRangeValue); static double between(double value, double min, double max); static long between(long value, long min, long max);  }
@Test public void testScaleBetween0And1() { double scaledValue = MathExt.scale(10.0, 0.0, 100.0); Assertions.assertThat(scaledValue).isEqualTo(0.1); }
@Test(expected = IllegalArgumentException.class) public void testScaleMinAndMaxValidation() { MathExt.scale(10.0, 10.0, 10.0); }
@Test public void testScaleBetween1and10() { double scaledValue = MathExt.scale(10.0, 0.0, 100.0, 0.0, 10.0); Assertions.assertThat(scaledValue).isEqualTo(1.0); }
@Test(expected = IllegalArgumentException.class) public void testScaleRangeValueValidation() { MathExt.scale(10.0, 9.0, 10.0, 10.0, 9.0); }