### Question:
BigDecimalPM extends TextPM implements IBigDecimalPM { public void setFormat(IFormat<BigDecimal> newFormat) { if (newFormat == null) { throw new IllegalArgumentException("newFormat == null"); } IFormat<BigDecimal> oldFormat = format; if (oldFormat == newFormat) { return; } boolean doReformat; BigDecimal oldValue = null; try { oldValue = getBigDecimal(); doReformat = true; } catch (ConversionException ex) { doReformat = false; } format = newFormat; revalidate(); getPropertyChangeSupport().firePropertyChange("format", oldFormat, newFormat); if (doReformat) { setBigDecimal(oldValue); } } BigDecimalPM(); @Override void reformat(); IFormat<BigDecimal> getFormat(); void setFormat(IFormat<BigDecimal> newFormat); void setBigDecimal(BigDecimal value); BigDecimal getBigDecimal(); void setDefaultBigDecimal(BigDecimal value); void setBigInteger(BigInteger value); BigInteger getBigInteger(); void setDefaultBigInteger(BigInteger value); @Override Comparable<?> getComparable();  }### Answer:
@Test public void settingAFormatDoesReformatText() { Locale.setDefault(Locale.GERMANY); BigDecimalPM pm = new BigDecimalPM(); DecimalFormat germanFormat = (DecimalFormat)NumberFormat.getNumberInstance(Locale.GERMANY); DecimalFormat usFormat = (DecimalFormat)NumberFormat.getNumberInstance(Locale.US); pm.setFormat(new BigDecimalPM.Format(germanFormat)); pm.setText("1.234.567,89"); pm.setFormat(new BigDecimalPM.Format(usFormat)); assertEquals("1,234,567.89", pm.getText()); }
@Test public void settingAFormatOnInvalidContentDoesNotReformatText() { Locale.setDefault(Locale.GERMANY); BigDecimalPM pm = new BigDecimalPM(); DecimalFormat germanFormat = (DecimalFormat)NumberFormat.getNumberInstance(Locale.GERMANY); DecimalFormat usFormat = (DecimalFormat)NumberFormat.getNumberInstance(Locale.US); pm.setFormat(new BigDecimalPM.Format(germanFormat)); pm.setText("abcxyz"); pm.setFormat(new BigDecimalPM.Format(usFormat)); assertEquals("abcxyz", pm.getText()); }
@Test public void textWithoutPercentSignIsValid() { BigDecimalPM pm = new BigDecimalPM(); pm.setFormat(new BigDecimalPM.Format(new DecimalFormat("#.##%"))); String input = "10"; pm.setText(input); assertEquals("pm.isValid()", true, pm.isValid()); }