@Test public void testConvert() { final CurrencyModel currencyModel = mock(CurrencyModel.class); given(currencyModel.getName()).willReturn(ISOCODE); given(currencyModel.getIsocode()).willReturn(ISOCODE); given(currencyModel.getActive()).willReturn(Boolean.TRUE); given(currencyModel.getSymbol()).willReturn(ISOCODE); final CurrencyData currencyData = currencyConverter.convert(currencyModel); Assert.assertEquals(currencyModel.getIsocode(), currencyData.getIsocode()); Assert.assertEquals(currencyModel.getActive(), Boolean.valueOf(currencyData.isActive())); Assert.assertEquals(currencyModel.getSymbol(), currencyData.getSymbol()); Assert.assertEquals(currencyModel.getName(), currencyData.getName()); }
/** Adjusts {@link DecimalFormat}'s symbol according to given {@link CurrencyModel}. */ protected DecimalFormat adjustSymbol( final DecimalFormat format, final CurrencyModel currencyModel) { final String symbol = currencyModel.getSymbol(); if (symbol != null) { final DecimalFormatSymbols symbols = format.getDecimalFormatSymbols(); // does cloning final String iso = currencyModel.getIsocode(); boolean changed = false; if (!iso.equalsIgnoreCase(symbols.getInternationalCurrencySymbol())) { symbols.setInternationalCurrencySymbol(iso); changed = true; } if (!symbol.equals(symbols.getCurrencySymbol())) { symbols.setCurrencySymbol(symbol); changed = true; } if (changed) { format.setDecimalFormatSymbols(symbols); } } return format; }