### Question:
DiscountingRatePaymentPeriodPricer implements SwapPaymentPeriodPricer<RatePaymentPeriod> { @Override public PointSensitivityBuilder forecastValueSensitivity(RatePaymentPeriod period, RatesProvider provider) { if (period.getPaymentDate().isBefore(provider.getValuationDate())) { return PointSensitivityBuilder.none(); } PointSensitivityBuilder sensiFx = fxRateSensitivity(period, provider); double accrual = accrualWithNotional(period, period.getNotional(), provider); sensiFx = sensiFx.multipliedBy(accrual); PointSensitivityBuilder sensiAccrual = PointSensitivityBuilder.none(); if (period.isCompoundingApplicable()) { sensiAccrual = accrueCompoundedSensitivity(period, provider); } else { sensiAccrual = unitNotionalSensitivityNoCompounding(period, provider); } double notional = period.getNotional() * fxRate(period, provider); sensiAccrual = sensiAccrual.multipliedBy(notional); return sensiFx.combinedWith(sensiAccrual); } DiscountingRatePaymentPeriodPricer(
      RateComputationFn<RateComputation> rateComputationFn); @Override double presentValue(RatePaymentPeriod period, RatesProvider provider); @Override double forecastValue(RatePaymentPeriod period, RatesProvider provider); @Override double pvbp(RatePaymentPeriod paymentPeriod, RatesProvider provider); @Override double accruedInterest(RatePaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder presentValueSensitivity(RatePaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder forecastValueSensitivity(RatePaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder pvbpSensitivity(RatePaymentPeriod paymentPeriod, RatesProvider provider); @Override void explainPresentValue(RatePaymentPeriod paymentPeriod, RatesProvider provider, ExplainMapBuilder builder); @Override MultiCurrencyAmount currencyExposure(RatePaymentPeriod period, RatesProvider provider); @Override double currentCash(RatePaymentPeriod period, RatesProvider provider); static final DiscountingRatePaymentPeriodPricer DEFAULT; }### Answer:
@Test public void test_forecastValueSensitivity_ibor_noCompounding() { RatesProvider mockProv = mock(RatesProvider.class); RateComputationFn<RateComputation> obsFunc = mock(RateComputationFn.class); when(mockProv.getValuationDate()).thenReturn(VAL_DATE); DiscountingRatePaymentPeriodPricer pricer = new DiscountingRatePaymentPeriodPricer(obsFunc); LocalDate[] dates = new LocalDate[] {CPN_DATE_1, CPN_DATE_2, CPN_DATE_3, CPN_DATE_4}; double[] rates = new double[] {RATE_1, RATE_2, RATE_3}; for (int i = 0; i < 3; ++i) { IborRateComputation rateObs = (IborRateComputation) PAYMENT_PERIOD_FLOATING.getAccrualPeriods().get(i).getRateComputation(); IborRateSensitivity iborSense = IborRateSensitivity.of(rateObs.getObservation(), 1.0d); when(obsFunc.rateSensitivity(rateObs, dates[i], dates[i + 1], mockProv)).thenReturn(iborSense); when(obsFunc.rate(rateObs, dates[i], dates[i + 1], mockProv)).thenReturn(rates[i]); } PointSensitivities senseComputed = pricer.forecastValueSensitivity(PAYMENT_PERIOD_FLOATING, mockProv).build(); double eps = 1.e-7; List<IborRateSensitivity> senseExpectedList = futureFwdSensitivityFD(mockProv, PAYMENT_PERIOD_FLOATING, obsFunc, eps); PointSensitivities senseExpected = PointSensitivities.of(senseExpectedList); assertThat(senseComputed.equalWithTolerance(senseExpected, eps * PAYMENT_PERIOD_FLOATING.getNotional())).isTrue(); }