### Question:
SabrExtrapolationReplicationCmsLegPricer { public CurrencyAmount presentValue( ResolvedCmsLeg cmsLeg, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities) { validate(ratesProvider, swaptionVolatilities); return cmsLeg.getCmsPeriods().stream() .map(cmsPeriod -> cmsPeriodPricer.presentValue(cmsPeriod, ratesProvider, swaptionVolatilities)) .reduce((c1, c2) -> c1.plus(c2)) .get(); } SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer cmsPeriodPricer); CurrencyAmount presentValue(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider,
      SabrSwaptionVolatilities swaptionVolatilities); ExplainMap explainPresentValue(
      ResolvedCmsLeg cmsLeg,
      RatesProvider provider,
      SabrSwaptionVolatilities volatilities); PointSensitivityBuilder presentValueSensitivityRates(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider,
      SabrSwaptionVolatilities swaptionVolatilities); PointSensitivityBuilder presentValueSensitivityModelParamsSabr(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider,
      SabrSwaptionVolatilities swaptionVolatilities); double presentValueSensitivityStrike(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider,
      SabrSwaptionVolatilities swaptionVolatilities); CurrencyAmount currentCash(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider,
      SabrSwaptionVolatilities swaptionVolatilities);  }### Answer:
@Test public void test_presentValue() { CurrencyAmount computed = LEG_PRICER.presentValue(CAP_LEG, RATES_PROVIDER, VOLATILITIES); double expected = 0d; List<CmsPeriod> cms = CAP_LEG.getCmsPeriods(); int size = cms.size(); for (int i = 0; i < size; ++i) { expected += PERIOD_PRICER.presentValue(cms.get(i), RATES_PROVIDER, VOLATILITIES).getAmount(); } assertThat(computed.getCurrency()).isEqualTo(EUR); assertThat(computed.getAmount()).isCloseTo(expected, offset(NOTIONAL_VALUE_0 * TOL)); }
@Test public void test_presentValue_afterPay() { CurrencyAmount computed = LEG_PRICER.presentValue(FLOOR_LEG, RATES_PROVIDER_AFTER_PERIOD, VOLATILITIES_AFTER_PERIOD); double expected = 0d; List<CmsPeriod> cms = FLOOR_LEG.getCmsPeriods(); int size = cms.size(); for (int i = 1; i < size; ++i) { expected += PERIOD_PRICER.presentValue( cms.get(i), RATES_PROVIDER_AFTER_PERIOD, VOLATILITIES_AFTER_PERIOD).getAmount(); } assertThat(computed.getCurrency()).isEqualTo(EUR); assertThat(computed.getAmount()).isCloseTo(expected, offset(NOTIONAL_VALUE_0 * TOL)); }
@Test public void test_presentValue_ended() { CurrencyAmount computed = LEG_PRICER.presentValue(COUPON_LEG, RATES_PROVIDER_ENDED, VOLATILITIES_ENDED); assertThat(computed).isEqualTo(CurrencyAmount.zero(EUR)); }