### Question:
FormatUtils { public static DecimalFormat getDecimalFormat(final int decimalPlaces) { if (decimalPlaces < 0) { throw new IllegalArgumentException("decimalPlaces must be non-negative"); } final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(); decimalFormatSymbols.setDecimalSeparator('.'); final StringBuilder builder = new StringBuilder(); builder.append("#0"); if (decimalPlaces > 0) { builder.append('.'); final char[] zeros = new char[decimalPlaces]; Arrays.fill(zeros, '0'); builder.append(zeros); } final DecimalFormat format = new DecimalFormat(builder.toString(), decimalFormatSymbols); format.setGroupingUsed(false); return format; } private  FormatUtils(); static DecimalFormat getDefaultDecimalFormat(); static DecimalFormat getDecimalFormat(final int decimalPlaces); static String format(final double value, final int decimalPlaces);  }### Answer:
@Test public void decimalFormatCannotBeSpecifiedWithNegativeDecimalPlaces() { Assertions.assertThrows(IllegalArgumentException.class, () -> FormatUtils.getDecimalFormat(-1)); }
@Test public void decimalFormatWithCustomDecimalPlacesFormatsValuesCorrectly() { final DecimalFormat format = FormatUtils.getDecimalFormat(5); assertFiveDecimalPlaceFormatting(format::format); }