### Question:
DiscountingFxSingleProductPricer { public MultiCurrencyAmount presentValue(ResolvedFxSingle fx, RatesProvider provider) { if (provider.getValuationDate().isAfter(fx.getPaymentDate())) { return MultiCurrencyAmount.empty(); } CurrencyAmount pv1 = paymentPricer.presentValue(fx.getBaseCurrencyPayment(), provider); CurrencyAmount pv2 = paymentPricer.presentValue(fx.getCounterCurrencyPayment(), provider); return MultiCurrencyAmount.of(pv1, pv2); } DiscountingFxSingleProductPricer(
      DiscountingPaymentPricer paymentPricer); MultiCurrencyAmount presentValue(ResolvedFxSingle fx, RatesProvider provider); PointSensitivities presentValueSensitivity(ResolvedFxSingle fx, RatesProvider provider); double parSpread(ResolvedFxSingle fx, RatesProvider provider); MultiCurrencyAmount currencyExposure(ResolvedFxSingle product, RatesProvider provider); MultiCurrencyAmount currentCash(ResolvedFxSingle fx, LocalDate valuationDate); FxRate forwardFxRate(ResolvedFxSingle fx, RatesProvider provider); PointSensitivityBuilder forwardFxRatePointSensitivity(ResolvedFxSingle fx, RatesProvider provider); double forwardFxRateSpotSensitivity(ResolvedFxSingle fx, RatesProvider provider); static final DiscountingFxSingleProductPricer DEFAULT; }### Answer:
@Test public void test_presentValue() { MultiCurrencyAmount computed = PRICER.presentValue(FWD, PROVIDER); double expected1 = NOMINAL_USD * PROVIDER.discountFactor(USD, PAYMENT_DATE); double expected2 = -NOMINAL_USD * FX_RATE * PROVIDER.discountFactor(KRW, PAYMENT_DATE); assertThat(computed.getAmount(USD).getAmount()).isCloseTo(expected1, offset(NOMINAL_USD * TOL)); assertThat(computed.getAmount(KRW).getAmount()).isCloseTo(expected2, offset(NOMINAL_USD * TOL)); }
@Test public void test_presentValue_ended() { ResolvedFxSingle fwd = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE), PAYMENT_DATE_PAST); MultiCurrencyAmount computed = PRICER.presentValue(fwd, PROVIDER); assertThat(computed).isEqualTo(MultiCurrencyAmount.empty()); }