public static BigDecimal generateMaximumNumberWithPrecision(int precision) {
    return (new BigDecimal("10")).pow(precision).subtract(new BigDecimal("1"));
  }
@Test
  public void testGenerateMaximumNumberWithPrecision() {
    int[] testCases = { 1, 3, 10, 38, 128 };
    for (int precision : testCases) {
      BigDecimal bd = BigDecimalUtils.generateMaximumNumberWithPrecision(precision);
      assertEquals(bd.precision(), precision);
      assertEquals(bd.add(new BigDecimal("1")).precision(), precision + 1);
    }
  }