DecimalFormatMerger implements SinglePropertyValueMerger<String, Number> { @Override public String mergeObjects(Number value, String[] extraParam) { if (value == null) { return null; } DecimalFormat format = getDecimalFormat(extraParam); return format.format(value); }  @Override String mergeObjects(Number value, String[] extraParam); @Override boolean isRestoreSupported(String[] params); @Override Number restoreObject(String object, String[] params);  }
@Test(expected=IllegalArgumentException.class) public void testEmptyParams() { String[] params = {}; subject.mergeObjects(12.34, params); fail("Should not have reached this point"); }
@Test public void testDecimalFormatMerger() { double value = 0.101; final String testFormat = "% #,###.00"; String result = subject.mergeObjects(value, new String[] {testFormat}); assertEquals(new DecimalFormat(testFormat).format(value), result); }