### Question:
DiscountingSwapLegPricer { public PointSensitivityBuilder presentValueSensitivity(ResolvedSwapLeg leg, RatesProvider provider) { return legValueSensitivity( leg, provider, paymentPeriodPricer::presentValueSensitivity, paymentEventPricer::presentValueSensitivity); } DiscountingSwapLegPricer(
      SwapPaymentPeriodPricer<SwapPaymentPeriod> paymentPeriodPricer,
      SwapPaymentEventPricer<SwapPaymentEvent> paymentEventPricer); SwapPaymentPeriodPricer<SwapPaymentPeriod> getPeriodPricer(); SwapPaymentEventPricer<SwapPaymentEvent> getEventPricer(); CurrencyAmount presentValue(ResolvedSwapLeg leg, Currency currency, RatesProvider provider); CurrencyAmount presentValue(ResolvedSwapLeg leg, RatesProvider provider); CurrencyAmount forecastValue(ResolvedSwapLeg leg, RatesProvider provider); CurrencyAmount accruedInterest(ResolvedSwapLeg leg, RatesProvider provider); double pvbp(ResolvedSwapLeg leg, RatesProvider provider); double couponEquivalent(ResolvedSwapLeg leg, RatesProvider provider, double pvbp); PointSensitivityBuilder presentValueSensitivity(ResolvedSwapLeg leg, RatesProvider provider); PointSensitivityBuilder forecastValueSensitivity(ResolvedSwapLeg leg, RatesProvider provider); PointSensitivityBuilder pvbpSensitivity(ResolvedSwapLeg fixedLeg, RatesProvider provider); double annuityCash(ResolvedSwapLeg fixedLeg, double yield); double annuityCash(int nbPaymentsPerYear, int nbPeriods, double yield); ValueDerivatives annuityCash1(int nbPaymentsPerYear, int nbPeriods, double yield); ValueDerivatives annuityCash2(int nbPaymentsPerYear, int nbPeriods, double yield); ValueDerivatives annuityCash3(int nbPaymentsPerYear, int nbPeriods, double yield); ValueDerivatives annuityCashDerivative(ResolvedSwapLeg fixedLeg, double yield); CashFlows cashFlows(ResolvedSwapLeg leg, RatesProvider provider); ExplainMap explainPresentValue(ResolvedSwapLeg leg, RatesProvider provider); MultiCurrencyAmount currencyExposure(ResolvedSwapLeg leg, RatesProvider provider); CurrencyAmount currentCash(ResolvedSwapLeg leg, RatesProvider provider); static final DiscountingSwapLegPricer DEFAULT; }### Answer:
@Test public void test_presentValueSensitivity() { ResolvedSwapLeg expSwapLeg = IBOR_SWAP_LEG_REC_GBP; Currency ccy = GBP_LIBOR_3M.getCurrency(); IborRateSensitivity fwdSense = IborRateSensitivity.of(IBOR_RATE_COMP.getObservation(), 140.0); ZeroRateSensitivity dscSense = ZeroRateSensitivity.of(ccy, 3d, -162.0); PointSensitivityBuilder sensiPeriod = fwdSense.combinedWith(dscSense); PointSensitivityBuilder sensiEvent = ZeroRateSensitivity.of(ccy, 4d, -134.0); PointSensitivities expected = sensiPeriod.build().combinedWith(sensiEvent.build()); SwapPaymentPeriodPricer<SwapPaymentPeriod> mockPeriod = mock(SwapPaymentPeriodPricer.class); SwapPaymentEventPricer<SwapPaymentEvent> mockEvent = mock(SwapPaymentEventPricer.class); when(mockPeriod.presentValueSensitivity(expSwapLeg.getPaymentPeriods().get(0), MOCK_PROV)) .thenReturn(sensiPeriod); when(mockEvent.presentValueSensitivity(expSwapLeg.getPaymentEvents().get(0), MOCK_PROV)) .thenReturn(sensiEvent); DiscountingSwapLegPricer test = new DiscountingSwapLegPricer(mockPeriod, mockEvent); PointSensitivities res = test.presentValueSensitivity(expSwapLeg, MOCK_PROV).build(); assertThat(res.equalWithTolerance(expected, TOLERANCE)).isTrue(); }