### Question:
DispatchingSwapPaymentEventPricer implements SwapPaymentEventPricer<SwapPaymentEvent> { @Override public PointSensitivityBuilder forecastValueSensitivity(SwapPaymentEvent paymentEvent, RatesProvider provider) { if (paymentEvent instanceof NotionalExchange) { return notionalExchangePricer.forecastValueSensitivity((NotionalExchange) paymentEvent, provider); } else if (paymentEvent instanceof FxResetNotionalExchange) { return fxResetNotionalExchangePricer.forecastValueSensitivity((FxResetNotionalExchange) paymentEvent, provider); } else { throw new IllegalArgumentException("Unknown PaymentEvent type: " + paymentEvent.getClass().getSimpleName()); } } DispatchingSwapPaymentEventPricer(
      SwapPaymentEventPricer<NotionalExchange> notionalExchangePricer,
      SwapPaymentEventPricer<FxResetNotionalExchange> fxResetNotionalExchangePricer); @Override double presentValue(SwapPaymentEvent paymentEvent, RatesProvider provider); @Override PointSensitivityBuilder presentValueSensitivity(SwapPaymentEvent paymentEvent, RatesProvider provider); @Override double forecastValue(SwapPaymentEvent paymentEvent, RatesProvider provider); @Override PointSensitivityBuilder forecastValueSensitivity(SwapPaymentEvent paymentEvent, RatesProvider provider); @Override void explainPresentValue(SwapPaymentEvent paymentEvent, RatesProvider provider, ExplainMapBuilder builder); @Override MultiCurrencyAmount currencyExposure(SwapPaymentEvent paymentEvent, RatesProvider provider); @Override double currentCash(SwapPaymentEvent paymentEvent, RatesProvider provider); static final DispatchingSwapPaymentEventPricer DEFAULT; }### Answer:
@Test public void test_forecastValueSensitivity_unknownType() { SwapPaymentEvent mockPaymentEvent = mock(SwapPaymentEvent.class); DispatchingSwapPaymentEventPricer test = DispatchingSwapPaymentEventPricer.DEFAULT; assertThatIllegalArgumentException() .isThrownBy(() -> test.forecastValueSensitivity(mockPaymentEvent, MOCK_PROV)); }