### Question:
IsdaCdsProductPricer { public CurrencyAmount expectedLoss( ResolvedCds cds, CreditRatesProvider ratesProvider) { if (isExpired(cds, ratesProvider)) { return CurrencyAmount.of(cds.getCurrency(), 0d); } double recoveryRate = recoveryRate(cds, ratesProvider); Pair<CreditDiscountFactors, LegalEntitySurvivalProbabilities> rates = reduceDiscountFactors(cds, ratesProvider); double survivalProbability = rates.getSecond().survivalProbability(cds.getProtectionEndDate()); double el = (1d - recoveryRate) * (1d - survivalProbability); return CurrencyAmount.of(cds.getCurrency(), Math.abs(cds.getNotional()) * el); } IsdaCdsProductPricer(AccrualOnDefaultFormula formula); AccrualOnDefaultFormula getAccrualOnDefaultFormula(); double price(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      PriceType priceType,
      ReferenceData refData); PointSensitivityBuilder priceSensitivity(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); CurrencyAmount presentValue(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      PriceType priceType,
      ReferenceData refData); PointSensitivityBuilder presentValueSensitivity(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); double parSpread(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); PointSensitivityBuilder parSpreadSensitivity(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); double protectionLeg(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); double riskyAnnuity(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      PriceType priceType,
      ReferenceData refData); PointSensitivityBuilder riskyAnnuitySensitivity(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); CurrencyAmount rpv01(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      PriceType priceType,
      ReferenceData refData); CurrencyAmount recovery01(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); JumpToDefault jumpToDefault(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider,
      LocalDate referenceDate,
      ReferenceData refData); CurrencyAmount expectedLoss(
      ResolvedCds cds,
      CreditRatesProvider ratesProvider); static final IsdaCdsProductPricer DEFAULT; }### Answer:
@Test public void expectedLossTest() { CurrencyAmount computed = PRICER.expectedLoss(PRODUCT_BEFORE, RATES_PROVIDER); double survivalProb = CREDIT_CRVE.discountFactor(PRODUCT_BEFORE.getProtectionEndDate()); double expected = NOTIONAL * (1d - RECOVERY_RATES.getRecoveryRate()) * (1d - survivalProb); assertThat(computed.getCurrency()).isEqualTo(USD); assertThat(computed.getAmount()).isCloseTo(expected, offset(NOTIONAL * TOL)); }