### Question:
DiscountingSwapLegPricer { public CurrencyAmount forecastValue(ResolvedSwapLeg leg, RatesProvider provider) { return CurrencyAmount.of(leg.getCurrency(), forecastValueInternal(leg, provider)); } 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_forecastValue() { SwapPaymentPeriodPricer<SwapPaymentPeriod> mockPeriod = mock(SwapPaymentPeriodPricer.class); when(mockPeriod.forecastValue(IBOR_RATE_PAYMENT_PERIOD_REC_GBP, MOCK_PROV)) .thenReturn(1000d); SwapPaymentEventPricer<SwapPaymentEvent> mockEvent = mock(SwapPaymentEventPricer.class); when(mockEvent.forecastValue(NOTIONAL_EXCHANGE_REC_GBP, MOCK_PROV)) .thenReturn(1000d); DiscountingSwapLegPricer test = new DiscountingSwapLegPricer(mockPeriod, mockEvent); CurrencyAmount expected = CurrencyAmount.of(GBP, 2000d); assertThat(test.forecastValue(IBOR_SWAP_LEG_REC_GBP, MOCK_PROV)).isEqualTo(expected); }
@Test public void test_forecastValue_past() { SwapPaymentPeriodPricer<SwapPaymentPeriod> mockPeriod = mock(SwapPaymentPeriodPricer.class); SwapPaymentEventPricer<SwapPaymentEvent> mockEvent = mock(SwapPaymentEventPricer.class); DiscountingSwapLegPricer test = new DiscountingSwapLegPricer(mockPeriod, mockEvent); CurrencyAmount expected = CurrencyAmount.of(GBP, 0d); assertThat(test.forecastValue(IBOR_SWAP_LEG_REC_GBP, MOCK_PROV_FUTURE)).isEqualTo(expected); }