/**
* Test trivial case with zero par spreads, zero hazard rates. This is a test that the methods in {@link PresentValueCreditDefaultSwap} are in sync with {@link PresentValueLegacyCreditDefaultSwap}
*/
@Test
public void testCreditSpreadsEqualZero() {
final LegacyVanillaCreditDefaultSwapDefinition cds = CreditDefaultSwapDefinitionDataSets.getLegacyVanillaDefinition().withMaturityDate(VALUATION_DATE.plusYears(10));
final double contingentLeg = CALCULATOR.calculateContingentLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE);
final double cleanRiskyAnnuity = CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE, PriceType.CLEAN);
final double dirtyRiskyAnnuity = CALCULATOR.calculatePremiumLeg(VALUATION_DATE, cds, YIELD_CURVE, ZERO_HAZARD_CURVE, PriceType.DIRTY);
final double cleanPremiumLeg = -cleanRiskyAnnuity * cds.getParSpread() / BP;
final double dirtyPremiumLeg = -dirtyRiskyAnnuity * cds.getParSpread() / BP;
final double cleanPrice = CALCULATOR.calibrateAndGetPresentValue(VALUATION_DATE, cds, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE, PriceType.CLEAN);
final double dirtyPrice = CALCULATOR.calibrateAndGetPresentValue(VALUATION_DATE, cds, MARKET_TENORS, ZERO_SPREADS, YIELD_CURVE, PriceType.DIRTY);
assertEquals(0, contingentLeg, EPS);
assertEquals(cleanPremiumLeg / cleanPrice - 1.0, 0.0, EPS);
assertEquals(dirtyPremiumLeg / dirtyPrice - 1.0, 0.0, EPS);