### Question:
FxRateImpl implements FxRate { @Override public CurrencyAmount getPaymentAmountForBuying(final CurrencyAmount amountToBuy) { boolean inverse = amountToBuy.getCurrency().equals(currencyPair.getCcy2()); final String targetCcy = inverse ? currencyPair.getCcy1() : currencyPair.getCcy2(); int decPlace = DEC_PLACE_FOR_MONEY; try { decPlace = Currency.getInstance(targetCcy).getDefaultFractionDigits(); } catch (IllegalArgumentException iae) { } return inverse ? new Cash(targetCcy, setScale( BigDecimalUtil.divide(PRECISION_FOR_INVERSE, amountToBuy.getAmount(), bid, BigDecimal.ROUND_HALF_UP), decPlace)) : new Cash( targetCcy, setScale(amountToBuy.getAmount().multiply(ask), decPlace)); } FxRateImpl(final CurrencyPair currencyPair, final String crossCcy, final boolean marketConvention, final BigDecimal bid,
            final BigDecimal ask, CurrencyProvider currencyProvider); @Override String getDescription(); @Override FxRate createInverse(); @Override FxRate createInverse(final int precision); @Override BigDecimal getBid(); @Override BigDecimal getAsk(); @Override CurrencyPair getCurrencyPair(); @Override Optional<String> getCrossCcy(); @Override boolean isMarketConvention(); @Override BigDecimal getMid(); @Override BigDecimal getBidInMarketConvention(); @Override BigDecimal getMidInMarketConvention(); @Override BigDecimal getAskInMarketConvention(); @Override String toString(); @Override CurrencyAmount convertAmountUsingMid(final CurrencyAmount originalAmount); @Override CurrencyAmount convertAmountUsingBidOrAsk(final CurrencyAmount originalAmount); @Override CurrencyAmount getPaymentAmountForBuying(final CurrencyAmount amountToBuy); @Override CurrencyAmount getReceiptAmountForSelling(final CurrencyAmount amountToSell);  }### Answer:
@Test public void testGetPaymentAmountForBuying() { FxRateImpl f = new FxRateImpl(CurrencyPair.of("EUR", "USD"), null, true, BigDecimalUtil.bd("1.6"), BigDecimalUtil.bd("1.61"), new JdkCurrencyProvider()); final CurrencyAmount paymentAmountForBuying = f.getPaymentAmountForBuying(Cash.of("USD", BigDecimalUtil.bd("1000"))); assertThat(paymentAmountForBuying.getCurrency()).isEqualTo("EUR"); assertThat(paymentAmountForBuying.getAmount()).isEqualByComparingTo("625"); final CurrencyAmount paymentAmountForBuying2 = f.getPaymentAmountForBuying(Cash.of("EUR", BigDecimalUtil.bd("1000"))); assertThat(paymentAmountForBuying2.getCurrency()).isEqualTo("USD"); assertThat(paymentAmountForBuying2.getAmount()).isEqualByComparingTo("1610"); }