### Question:
DiscountingFixedCouponBondPaymentPeriodPricer { public double presentValueWithSpread( FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { if (period.getPaymentDate().isBefore(discountFactors.getValuationDate())) { return 0d; } double df = discountFactors.getDiscountFactors() .discountFactorWithSpread(period.getPaymentDate(), zSpread, compoundedRateType, periodsPerYear); return period.getFixedRate() * period.getNotional() * period.getYearFraction() * df; } DiscountingFixedCouponBondPaymentPeriodPricer(); double presentValue(FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors); double presentValueWithSpread(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors,
      double zSpread,
      CompoundedRateType compoundedRateType,
      int periodsPerYear); double forecastValue(FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors); PointSensitivityBuilder presentValueSensitivity(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors); PointSensitivityBuilder presentValueSensitivityWithSpread(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors,
      double zSpread,
      CompoundedRateType compoundedRateType,
      int periodsPerYear); PointSensitivityBuilder forecastValueSensitivity(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors); void explainPresentValue(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors,
      ExplainMapBuilder builder); void explainPresentValueWithSpread(
      FixedCouponBondPaymentPeriod period,
      IssuerCurveDiscountFactors discountFactors,
      ExplainMapBuilder builder,
      double zSpread,
      CompoundedRateType compoundedRateType,
      int periodsPerYear); static final DiscountingFixedCouponBondPaymentPeriodPricer DEFAULT; }### Answer:
@Test public void test_presentValueWithSpread() { double computed = PRICER.presentValueWithSpread( PAYMENT_PERIOD, ISSUER_CURVE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double expected = FIXED_RATE * NOTIONAL * YEAR_FRACTION * DSC_FACTORS.discountFactorWithSpread(END_ADJUSTED, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertThat(computed).isEqualTo(expected); }
@Test public void test_presentValueWithSpread_past() { double computed = PRICER.presentValueWithSpread( PAYMENT_PERIOD, ISSUER_CURVE_AFTER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertThat(computed).isEqualTo(0d); }