### Question:
DiscountingPaymentPricer { public PointSensitivityBuilder presentValueSensitivity(Payment payment, BaseProvider provider) { if (provider.getValuationDate().isAfter(payment.getDate())) { return PointSensitivityBuilder.none(); } DiscountFactors discountFactors = provider.discountFactors(payment.getCurrency()); return discountFactors.zeroRatePointSensitivity(payment.getDate()).multipliedBy(payment.getAmount()); } DiscountingPaymentPricer(); CurrencyAmount presentValue(Payment payment, BaseProvider provider); CurrencyAmount presentValue(Payment payment, DiscountFactors discountFactors); double presentValueAmount(Payment payment, BaseProvider provider); CurrencyAmount presentValueWithSpread(
      Payment payment,
      DiscountFactors discountFactors,
      double zSpread,
      CompoundedRateType compoundedRateType,
      int periodsPerYear); ExplainMap explainPresentValue(Payment payment, BaseProvider provider); PointSensitivityBuilder presentValueSensitivity(Payment payment, BaseProvider provider); PointSensitivityBuilder presentValueSensitivity(Payment payment, DiscountFactors discountFactors); PointSensitivityBuilder presentValueSensitivityWithSpread(
      Payment payment,
      DiscountFactors discountFactors,
      double zSpread,
      CompoundedRateType compoundedRateType,
      int periodsPerYear); CurrencyAmount forecastValue(Payment payment, BaseProvider provider); double forecastValueAmount(Payment payment, BaseProvider provider); CashFlows cashFlows(Payment payment, BaseProvider provider); MultiCurrencyAmount currencyExposure(Payment payment, BaseProvider provider); CurrencyAmount currentCash(Payment payment, BaseProvider provider); static final DiscountingPaymentPricer DEFAULT; }### Answer:
@Test public void test_presentValueSensitivity_provider() { PointSensitivities point = PRICER.presentValueSensitivity(PAYMENT, PROVIDER).build(); double relativeYearFraction = ACT_365F.relativeYearFraction(VAL_DATE_2014_01_22, PAYMENT_DATE); double expected = -DF * relativeYearFraction * NOTIONAL_USD; ZeroRateSensitivity actual = (ZeroRateSensitivity) point.getSensitivities().get(0); assertThat(actual.getCurrency()).isEqualTo(USD); assertThat(actual.getCurveCurrency()).isEqualTo(USD); assertThat(actual.getYearFraction()).isEqualTo(relativeYearFraction); assertThat(actual.getSensitivity()).isCloseTo(expected, offset(NOTIONAL_USD * TOL)); }
@Test public void test_presentValueSensitivity_provider_ended() { PointSensitivities computed = PRICER.presentValueSensitivity(PAYMENT_PAST, PROVIDER).build(); assertThat(computed).isEqualTo(PointSensitivities.empty()); }
@Test public void test_presentValueSensitivity_df() { PointSensitivities point = PRICER.presentValueSensitivity(PAYMENT, DISCOUNT_FACTORS).build(); double relativeYearFraction = ACT_365F.relativeYearFraction(VAL_DATE_2014_01_22, PAYMENT_DATE); double expected = -DF * relativeYearFraction * NOTIONAL_USD; ZeroRateSensitivity actual = (ZeroRateSensitivity) point.getSensitivities().get(0); assertThat(actual.getCurrency()).isEqualTo(USD); assertThat(actual.getCurveCurrency()).isEqualTo(USD); assertThat(actual.getYearFraction()).isEqualTo(relativeYearFraction); assertThat(actual.getSensitivity()).isCloseTo(expected, offset(NOTIONAL_USD * TOL)); }
@Test public void test_presentValueSensitivity_df_ended() { PointSensitivities computed = PRICER.presentValueSensitivity(PAYMENT_PAST, DISCOUNT_FACTORS).build(); assertThat(computed).isEqualTo(PointSensitivities.empty()); }