InterestRate { public abstract PeriodicInterestRate toPeriodic(int periodsPerYear); InterestRate(final double rate); double getRate(); abstract double getDiscountFactor(double t); abstract InterestRate fromContinuous(ContinuousInterestRate continuous); abstract double fromContinuousDerivative(ContinuousInterestRate continuous); abstract InterestRate fromPeriodic(PeriodicInterestRate periodic); abstract ContinuousInterestRate toContinuous(); abstract PeriodicInterestRate toPeriodic(int periodsPerYear); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeNumberOfPeriods1() { ANNUAL.toPeriodic(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeNumberOfPeriods2() { CONTINUOUS.toPeriodic(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNegativeNumberOfPeriods3() { QUARTERLY.toPeriodic(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testZeroNumberOfPeriods1() { ANNUAL.toPeriodic(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testZeroNumberOfPeriods2() { CONTINUOUS.toPeriodic(-3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testZeroNumberOfPeriods3() { QUARTERLY.toPeriodic(-3); }