### Question:
DiscountingCmsPeriodPricer { public double forwardRate( CmsPeriod cmsPeriod, RatesProvider provider) { LocalDate fixingDate = cmsPeriod.getFixingDate(); LocalDate valuationDate = provider.getValuationDate(); if (!fixingDate.isAfter(valuationDate)) { throw new IllegalArgumentException("Forward rate is availaible only for valuation date after the fixing date"); } ResolvedSwap swap = cmsPeriod.getUnderlyingSwap(); return swapPricer.parRate(swap, provider); } DiscountingCmsPeriodPricer(
      DiscountingSwapProductPricer swapPricer); CurrencyAmount presentValue(
      CmsPeriod cmsPeriod,
      RatesProvider provider); double forwardRate(
      CmsPeriod cmsPeriod,
      RatesProvider provider); PointSensitivityBuilder presentValueSensitivity(
      CmsPeriod cmsPeriod,
      RatesProvider provider); static final DiscountingCmsPeriodPricer DEFAULT; }### Answer:
@Test public void forward_rate() { double fwdComputed = PRICER_CMS.forwardRate(COUPON, RATES_PROVIDER); double fwdExpected = PRICER_SWAP.parRate(COUPON.getUnderlyingSwap(), RATES_PROVIDER); assertThat(fwdComputed).isCloseTo(fwdExpected, offset(TOLERANCE_DELTA)); }
@Test public void forward_rate_after_fixing() { assertThatIllegalArgumentException() .isThrownBy(() -> PRICER_CMS.forwardRate(COUPON, RATES_PROVIDER_AFTER_FIX)); }