### Question:
DiscountingFraProductPricer { public CurrencyAmount forecastValue(ResolvedFra fra, RatesProvider provider) { double fv = forecastValue0(fra, provider); return CurrencyAmount.of(fra.getCurrency(), fv); } DiscountingFraProductPricer(
      RateComputationFn<RateComputation> rateComputationFn); CurrencyAmount presentValue(ResolvedFra fra, RatesProvider provider); PointSensitivities presentValueSensitivity(ResolvedFra fra, RatesProvider provider); CurrencyAmount forecastValue(ResolvedFra fra, RatesProvider provider); PointSensitivities forecastValueSensitivity(ResolvedFra fra, RatesProvider provider); double parRate(ResolvedFra fra, RatesProvider provider); PointSensitivities parRateSensitivity(ResolvedFra fra, RatesProvider provider); double parSpread(ResolvedFra fra, RatesProvider provider); PointSensitivities parSpreadSensitivity(ResolvedFra fra, RatesProvider provider); CashFlows cashFlows(ResolvedFra fra, RatesProvider provider); ExplainMap explainPresentValue(ResolvedFra fra, RatesProvider provider); static final DiscountingFraProductPricer DEFAULT; }### Answer:
@Test public void test_forecastValue_ISDA() { SimpleRatesProvider prov = createProvider(RFRA); double fixedRate = FRA.getFixedRate(); double yearFraction = RFRA.getYearFraction(); double notional = RFRA.getNotional(); double expected = notional * yearFraction * (FORWARD_RATE - fixedRate) / (1.0 + yearFraction * FORWARD_RATE); DiscountingFraProductPricer test = DiscountingFraProductPricer.DEFAULT; CurrencyAmount computed = test.forecastValue(RFRA, prov); assertThat(computed.getAmount()).isCloseTo(expected, offset(TOLERANCE)); DiscountingFraTradePricer testTrade = new DiscountingFraTradePricer(test); assertThat(testTrade.forecastValue(RFRA_TRADE, prov)).isEqualTo(test.forecastValue(RFRA, prov)); }
@Test public void test_forecastValue_NONE() { SimpleRatesProvider prov = createProvider(RFRA_NONE); double fixedRate = FRA_NONE.getFixedRate(); double yearFraction = RFRA_NONE.getYearFraction(); double notional = RFRA_NONE.getNotional(); double expected = notional * yearFraction * (FORWARD_RATE - fixedRate); DiscountingFraProductPricer test = DiscountingFraProductPricer.DEFAULT; CurrencyAmount computed = test.forecastValue(RFRA_NONE, prov); assertThat(computed.getAmount()).isCloseTo(expected, offset(TOLERANCE)); }
@Test public void test_forecastValue_AFMA() { SimpleRatesProvider prov = createProvider(RFRA_AFMA); double fixedRate = FRA_AFMA.getFixedRate(); double yearFraction = RFRA_AFMA.getYearFraction(); double notional = RFRA_AFMA.getNotional(); double expected = -notional * (1.0 / (1.0 + yearFraction * FORWARD_RATE) - 1.0 / (1.0 + yearFraction * fixedRate)); DiscountingFraProductPricer test = DiscountingFraProductPricer.DEFAULT; CurrencyAmount computed = test.forecastValue(RFRA_AFMA, prov); assertThat(computed.getAmount()).isCloseTo(expected, offset(TOLERANCE)); }
@Test public void test_forecastValue_inPast() { SimpleRatesProvider prov = createProvider(RFRA.toBuilder().paymentDate(VAL_DATE.minusDays(1)).build()); DiscountingFraProductPricer test = DiscountingFraProductPricer.DEFAULT; CurrencyAmount computed = test.forecastValue(RFRA.toBuilder().paymentDate(VAL_DATE.minusDays(1)).build(), prov); assertThat(computed.getAmount()).isCloseTo(0d, offset(TOLERANCE)); }