### Question:
DiscountingCmsLegPricer { public CurrencyAmount currentCash( ResolvedCmsLeg cmsLeg, RatesProvider ratesProvider) { return cmsLeg.getCmsPeriods() .stream() .filter(x -> x.getPaymentDate().equals(ratesProvider.getValuationDate())) .map(x -> cmsPeriodPricer.presentValue(x, ratesProvider)) .reduce((c1, c2) -> c1.plus(c2)) .orElse(CurrencyAmount.zero(cmsLeg.getCurrency())); } DiscountingCmsLegPricer(DiscountingCmsPeriodPricer cmsPeriodPricer); CurrencyAmount presentValue(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider); PointSensitivityBuilder presentValueSensitivity(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider); CurrencyAmount currentCash(
      ResolvedCmsLeg cmsLeg,
      RatesProvider ratesProvider);  }### Answer:
@Test public void test_currentCash() { CurrencyAmount computed = LEG_PRICER.currentCash(COUPON_LEG, RATES_PROVIDER); assertThat(computed).isEqualTo(CurrencyAmount.zero(EUR)); }
@Test public void test_currentCash_onPay() { CurrencyAmount computed = LEG_PRICER.currentCash(COUPON_LEG, RATES_PROVIDER_ON_PAY); assertThat(computed.getAmount()).isCloseTo(-NOTIONAL_VALUE_1 * OBS_INDEX * 367d / 360d, offset(TOLERANCE_PV)); }