BusinessTwoFiveTwo extends StatelessDayCount { @Override public double getDayCountFraction(final LocalDate firstDate, final LocalDate secondDate) { throw new UnsupportedOperationException("Must supply a calendar to calculate the day-count fraction"); }  @Override double getDayCountFraction(final LocalDate firstDate, final LocalDate secondDate); @Override double getDayCountFraction(final ZonedDateTime firstDate, final ZonedDateTime secondDate); @Override double getDayCountFraction(final LocalDate firstDate, final LocalDate secondDate, final Calendar calendar); @Override double getDayCountFraction(final ZonedDateTime firstDate, final ZonedDateTime secondDate, final Calendar calendar); @Override double getAccruedInterest(final LocalDate previousCouponDate, final LocalDate date, final LocalDate nextCouponDate, final double coupon, final double paymentsPerYear); @Override String getName();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFirstDate1() { DC.getDayCountFraction(null, D2, WEEKEND_CALENDAR); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullSecondDate1() { DC.getDayCountFraction(D1, null, WEEKEND_CALENDAR); }
@Test(expectedExceptions = OpenGammaRuntimeException.class) public void testWrongOrder1() { DC.getDayCountFraction(D2, D1, WEEKEND_CALENDAR); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFirstDate2() { DC.getDayCountFraction(null, D5, WEEKEND_CALENDAR); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullSecondDate2() { DC.getDayCountFraction(D4, null, WEEKEND_CALENDAR); }
@Test(expectedExceptions = OpenGammaRuntimeException.class) public void testWrongOrder2() { DC.getDayCountFraction(D5, D4, WEEKEND_CALENDAR); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testNoCalendar1() { DC.getDayCountFraction(D4, D5); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testNoCalendar2() { DC.getDayCountFraction(D1, D3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCalendar1() { DC.getDayCountFraction(D4, D5, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCalendar2() { DC.getDayCountFraction(D1, D2, null); }
@Test public void additivityTest() { LocalDate d1 = LocalDate.of(2014, 7, 16); LocalDate d2 = LocalDate.of(2014, 8, 17); double yf = DC.getDayCountFraction(d1, d2, WEEKEND_CALENDAR); LocalDate d = d1; while (!d.isAfter(d2)) { assertEquals(yf, DC.getDayCountFraction(d1, d, WEEKEND_CALENDAR) + DC.getDayCountFraction(d, d2, WEEKEND_CALENDAR), 1e-15); d = d.plusDays(1); } }