### Question:
ExchangeRatesServiceImpl implements ExchangeRatesService { @Override @CatAnnotation public BigDecimal convert(Currency from, Currency to, BigDecimal amount) { Assert.notNull(amount); Map<Currency, BigDecimal> rates = getCurrentRates(); BigDecimal ratio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP); return amount.multiply(ratio); }  @Override @CatAnnotation Map<Currency, BigDecimal> getCurrentRates(); @Override @CatAnnotation BigDecimal convert(Currency from, Currency to, BigDecimal amount);  }### Answer:
@Test public void shouldConvertCurrency() { ExchangeRatesContainer container = new ExchangeRatesContainer(); container.setRates(ImmutableMap.of( Currency.EUR.name(), new BigDecimal("0.8"), Currency.RUB.name(), new BigDecimal("80") )); when(client.getRates(Currency.getBase())).thenReturn(container); final BigDecimal amount = new BigDecimal(100); final BigDecimal expectedConvertionResult = new BigDecimal("1.25"); BigDecimal result = ratesService.convert(Currency.RUB, Currency.USD, amount); assertTrue(expectedConvertionResult.compareTo(result) == 0); }
@Test(expected = IllegalArgumentException.class) public void shouldFailToConvertWhenAmountIsNull() { ratesService.convert(Currency.EUR, Currency.RUB, null); }