@SuppressWarnings("deprecation")
@Test
public void toDerivativeUSTDeprecated() {
final BondFixedSecurity bondConverted = BOND_SECURITY_DEFINITION.toDerivative(REFERENCE_DATE_1, CURVES_NAME);
AnnuityPaymentFixedDefinition nominalDefinition = (AnnuityPaymentFixedDefinition) BOND_SECURITY_DEFINITION.getNominal();
AnnuityCouponFixedDefinition couponDefinition = BOND_SECURITY_DEFINITION.getCoupons();
final ZonedDateTime spotDate1 = ScheduleCalculator.getAdjustedDate(REFERENCE_DATE_1, SETTLEMENT_DAYS, CALENDAR);
nominalDefinition = nominalDefinition.trimBefore(spotDate1);
couponDefinition = couponDefinition.trimBefore(spotDate1);
final AnnuityPaymentFixed nominal = nominalDefinition.toDerivative(REFERENCE_DATE_1, CURVES_NAME);
final AnnuityCouponFixed coupon = couponDefinition.toDerivative(REFERENCE_DATE_1, CURVES_NAME);
final double spotTime1 = ACT_ACT.getDayCountFraction(REFERENCE_DATE_1, spotDate1);
final double accruedInterest = DAY_COUNT.getAccruedInterest(couponDefinition.getNthPayment(0).getAccrualStartDate(), spotDate1, couponDefinition.getNthPayment(0)
.getAccrualEndDate(), RATE, COUPON_PER_YEAR)
* NOTIONAL;
final double factorSpot = DAY_COUNT.getAccruedInterest(couponDefinition.getNthPayment(0).getAccrualStartDate(), spotDate1, couponDefinition.getNthPayment(0)
.getAccrualEndDate(), RATE, COUPON_PER_YEAR);
final double factorPeriod = DAY_COUNT.getAccruedInterest(couponDefinition.getNthPayment(0).getAccrualStartDate(), couponDefinition.getNthPayment(0)
.getAccrualEndDate(), couponDefinition.getNthPayment(0).getAccrualEndDate(), RATE, COUPON_PER_YEAR);
final double factorToNextCoupon = (factorPeriod - factorSpot) / factorPeriod;
final BondFixedSecurity bondExpected = new BondFixedSecurity(nominal, coupon, spotTime1, accruedInterest, factorToNextCoupon, YIELD_CONVENTION, COUPON_PER_YEAR,
REPO_CURVE_NAME, "");
assertEquals("Bond Fixed Security Definition to derivative", bondConverted.getAccrualFactorToNextCoupon(), bondExpected.getAccrualFactorToNextCoupon(), 1.0E-10);
assertEquals("Bond Fixed Security Definition to derivative", bondConverted.getAccruedInterest(), bondExpected.getAccruedInterest(), 1.0E-10);