YieldSensitivityCalculator { public double calculateNthOrderSensitivity(final Annuity<? extends PaymentFixed> annuity, final double pv, final int order) { Validate.notNull(annuity, "annuity"); final double yield = calculateYield(annuity, pv); return calculateNthOrderSensitivityFromYield(annuity, yield, order); } private  YieldSensitivityCalculator(); static YieldSensitivityCalculator getInstance(); double calculateYield(final Annuity<? extends PaymentFixed> annuity, final double pv); double calculateYield(final AnnuityCouponFixed annuity, final double pv); double calculatePriceForYield(final Annuity<? extends PaymentFixed> annuity, final double yield); double calculatePriceForYield(final AnnuityCouponFixed annuity, final double yield); double calculateNthOrderSensitivity(final Annuity<? extends PaymentFixed> annuity, final double pv, final int order); double calculateNthOrderSensitivity(final AnnuityCouponFixed annuity, final double pv, final int order); double calculateNthOrderSensitivityFromYield(final Annuity<? extends PaymentFixed> annuity, final double yield, final int order); double calculateNthOrderSensitivityFromYield(final AnnuityCouponFixed annuity, final double yield, final int order);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullAnnuity3() { YSC.calculateNthOrderSensitivity((AnnuityCouponFixed) null, 1.0, 3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeOrder() { YSC.calculateNthOrderSensitivity(new AnnuityCouponFixed(new CouponFixed[] {new CouponFixed(CUR, 2, 2, 0.4)}), 1, -1); }