### Question:
DiscountingKnownAmountPaymentPeriodPricer implements SwapPaymentPeriodPricer<KnownAmountSwapPaymentPeriod> { @Override public PointSensitivityBuilder presentValueSensitivity(KnownAmountSwapPaymentPeriod period, RatesProvider provider) { return paymentPricer.presentValueSensitivity(period.getPayment(), provider); } DiscountingKnownAmountPaymentPeriodPricer(DiscountingPaymentPricer paymentPricer); @Override double presentValue(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override double forecastValue(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override double accruedInterest(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override double pvbp(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder presentValueSensitivity(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder forecastValueSensitivity(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override PointSensitivityBuilder pvbpSensitivity(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override void explainPresentValue(KnownAmountSwapPaymentPeriod period, RatesProvider provider, ExplainMapBuilder builder); @Override MultiCurrencyAmount currencyExposure(KnownAmountSwapPaymentPeriod period, RatesProvider provider); @Override double currentCash(KnownAmountSwapPaymentPeriod period, RatesProvider provider); static final DiscountingKnownAmountPaymentPeriodPricer DEFAULT; }### Answer:
@Test public void test_presentValueSensitivity() { SimpleRatesProvider prov = createProvider(VAL_DATE); PointSensitivities point = PRICER.presentValueSensitivity(PERIOD, prov).build(); double relativeYearFraction = DAY_COUNT.relativeYearFraction(VAL_DATE, PAYMENT_DATE); double expected = -DISCOUNT_FACTOR * relativeYearFraction * AMOUNT_1000; ZeroRateSensitivity actual = (ZeroRateSensitivity) point.getSensitivities().get(0); assertThat(actual.getCurrency()).isEqualTo(GBP); assertThat(actual.getCurveCurrency()).isEqualTo(GBP); assertThat(actual.getYearFraction()).isEqualTo(relativeYearFraction); assertThat(actual.getSensitivity()).isCloseTo(expected, offset(AMOUNT_1000 * TOLERANCE_PV)); }
@Test public void test_presentValueSensitivity_inPast() { SimpleRatesProvider prov = createProvider(VAL_DATE); PointSensitivities computed = PRICER.presentValueSensitivity(PERIOD_PAST, prov) .build(); assertThat(computed).isEqualTo(PointSensitivities.empty()); }